Einfach 0 gelöst 0% Erfolgsquote

Largest Digit

Find the largest decimal digit of a positive integer.

Look at every decimal digit of n and return the largest one.

Implement largest_digit(n).

Input

n: A positive integer.

Output

Return the largest digit, from 0 to 9.

Einschränkungen

1 ≤ n ≤ 10¹⁸

Beispiele

Beispiel 1
Eingabe:
n = 352

Erwartete Ausgabe:
expected = 5
Eingabe:
long long n = 352;

Erwartete Ausgabe:
long long expected = 5;
Eingabe:
long n = 352;

Erwartete Ausgabe:
long expected = 5;

Erläuterung

The digits are 3, 5 and 2; the largest is 5.

Beispiel 2
Eingabe:
n = 7

Erwartete Ausgabe:
expected = 7
Eingabe:
long long n = 7;

Erwartete Ausgabe:
long long expected = 7;
Eingabe:
long n = 7;

Erwartete Ausgabe:
long expected = 7;

Erläuterung

The only digit is 7.

Von anderen lernen

Community-Lösungen

Noch keine veröffentlichten Lösungen. Löse die Aufgabe und teile als Erster eine Lösung.