Easy 0 solved 0% acceptance

Largest Digit

Find the largest decimal digit of a positive integer.

Problem

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.

Constraints

1 ≤ n ≤ 10¹⁸

Examples

Example 1
Input:
n = 352

Expected output:
expected = 5
Input:
long long n = 352;

Expected output:
long long expected = 5;
Input:
long n = 352;

Expected output:
long expected = 5;

Explanation

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

Example 2
Input:
n = 7

Expected output:
expected = 7
Input:
long long n = 7;

Expected output:
long long expected = 7;
Input:
long n = 7;

Expected output:
long expected = 7;

Explanation

The only digit is 7.

Learn from others

Community solutions

No published solutions yet. Solve this challenge to share the first one.