問題
翻訳を表示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.
制約
1 ≤ n ≤ 10¹⁸
例
例 1
入力:
n = 352
期待される出力:
expected = 2
入力:
long long n = 352;
期待される出力:
long long expected = 2;
入力:
long n = 352;
期待される出力:
long expected = 2;
解説
The digits are 3, 5 and 2; the smallest is 2.
例 2
入力:
n = 1203
期待される出力:
expected = 0
入力:
long long n = 1203;
期待される出力:
long long expected = 0;
入力:
long n = 1203;
期待される出力:
long expected = 0;
解説
The 0 inside the number is the smallest digit.