Problema
Mostra traduzioneLook 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.
Vincoli
1 ≤ n ≤ 10¹⁸
Esempi
Esempio 1
Input:
n = 352
Output atteso:
expected = 5
Input:
long long n = 352;
Output atteso:
long long expected = 5;
Input:
long n = 352;
Output atteso:
long expected = 5;
Spiegazione
The digits are 3, 5 and 2; the largest is 5.
Esempio 2
Input:
n = 7
Output atteso:
expected = 7
Input:
long long n = 7;
Output atteso:
long long expected = 7;
Input:
long n = 7;
Output atteso:
long expected = 7;
Spiegazione
The only digit is 7.