Digital Roots
来源:互联网 发布:淘宝美白面膜排行榜 编辑:程序博客网 时间:2024/04/19 01:32
The digital root of a positive integer is found bysumming the digits of the integer. If the resulting value is asingle digit then that digit is the digital root. If the resultingvalue contains two o r more digits, those digits are summed and theprocess is repeated. This is continued as long as necessary toobtain a single digit.
For example, consider the positive integer 24. Adding the 2 andthe 4 yields a value of 6. Since 6 is a single digit, 6 is thedigital root of 24. Now consider the positive integer 39. Addingthe 3 and the 9 yields 12. Since 12 is not a single digit, theprocess must be repeated. Adding the 1 and the 2 yeilds 3, a singledigit and also the digital root of 39.
Sample Input
24 39 0
Sample Output
63
#include<iostream>
#include<cstring>
using namespace std;
int f(int n)
{
}
int main(){
char s[1024];
int n, i;
while (cin>>s){
}
return 0;
}
- Digital Roots
- HDOJ 1013 Digital Roots
- Digital Roots
- Digital Roots
- Digital Roots
- Digital Roots
- Digital Roots
- Digital Roots
- Digital Roots
- Digital Roots
- Digital Roots
- Digital Roots
- Digital Roots
- Digital Roots
- Digital Roots
- Digital Roots
- Digital Roots
- Digital Roots
- Sorting Again
- 拉丁方阵
- 沙漠储油点
- 逃跑的蠕虫
- 哥德巴赫猜想
- Digital Roots
- 翻转数的和
- 折半查找!
- 结构体!学生成绩管理!
- 富豪排行榜
- one + two = 3
- 从string中提取出数字
- HDU 1898 Sempr == The Best Problem Solver?(数学题)
- stringstream的用法