Easy 0 solved 0% acceptance

Smallest Digit

Find the smallest decimal digit of a positive integer.

Problem

Look at every decimal digit of n and return the smallest one. Zeros inside the number count.

Implement smallest_digit(n).

Input

n: A positive integer.

Output

Return the smallest digit, from 0 to 9.

Constraints

1 ≤ n ≤ 10¹⁸

Examples

Example 1
Input:
n = 352

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

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

Expected output:
long expected = 2;

Explanation

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

Example 2
Input:
n = 1203

Expected output:
expected = 0
Input:
long long n = 1203;

Expected output:
long long expected = 0;
Input:
long n = 1203;

Expected output:
long expected = 0;

Explanation

The 0 inside the number is the smallest digit.

Learn from others

Community solutions

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