英文题目:题目来源:https://acs.jxnu.edu.cn/problem/HDU1013
Digital Roots
1000ms 32768K
描述:
The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains two or more digits, those digits are summed and the process is repeated. This is continued as long as necessary to obtain a single digit.
For example, consider the positive integer 24. Adding the 2 and the 4 yields a value of 6. Since 6 is a single digit, 6 is the digital root of 24. Now consider the positive integer 39. Adding the 3 and the 9 yields 12. Since 12 is not a single digit, the process must be repeated. Adding the 1 and the 2 yeilds 3, a single digit and also the digital root of 39.
输入:
The input file will contain a list of positive integers, one per line. The end of the input will be indicated by an integer value of zero.
输出:
For each integer in the input, output its digital root on a separate line of the output.
翻译:
数字根
描述:
正整数的数字根是通过对整数的位数求和得到的。如果结果值是一个数字,则该数字是数字根。如果结果值包含两个或两个以上的数字,则将这些数字相加,并重复该过程。只要有必要获得一个位数,这一过程就会持续。
例如正整数24的数字根就是将2和4相加得到的值6。因为6是一个只有个位数的数字,所以6是24的数字根。现在考虑正整数39。加上3和9得到12。因为12不是一个只有个位数的数,所以必须重复以上过程,即加上1和2个字节3,符合题意,所以3是39的数字根。
输入:
每行输入一个正整数,当输入为空时结束输入。
输出:
为每行输入输出结果。