Description
對於所有正整數n,我們定義一函數f(n)為n的每一個十進位數字的總和,若再把f(n)代入函數中可得到n,f(n),f(f(n)),f(f(f(n)))…最後得到僅有一位數字的值,並定義該值為g(n)。
例如,當n=1234567892,則:
f(n)=1+2+3+4+5+6+7+8+9+2=47
f(n(n))=4+7=11
f(f(f(n)))=1+1=2
所以,g(1234567892)=2。
For all positive integers n, we define a function f(n) as the sum of each decimal digit of n. If f(n) is substituted into the function, we can get n,f(n),f(f(n) ),f(f(f(n)))... Finally, a value with only one digit is obtained, and the value is defined as g(n).
For example, when n=1234567892, then:
f(n)=1+2+3+4+5+6+7+8+9+2=47
f(n(n))=4+7=11
f(f(f(n)))=1+1=2
Therefore, g(1234567892)=2.
Input
輸入的每一行會有一個正整數n,其值不超過 int 的大小,你必須輸出g(n)。
Each line of input will have a positive integer n whose value does not exceed the size of an int, and you must output g(n).
Output
輸出 g(n) 的結果。
Output the result of g(n).
Sample Input 1