Advertisement
Courbe_Impliquee

Цифровой корень

Mar 1st, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. // ConsoleApplication27.cpp: определяет точку входа для консольного приложения.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "stdio.h"
  6. #include <iostream>
  7. #include <cmath>
  8. using namespace std;
  9.  
  10. int sum(int a){
  11. if (a > 10){
  12. return sum(a % 10 + sum(a / 10));
  13. }
  14. else return a;
  15. }
  16.  
  17. int _tmain(int argc, _TCHAR* argv[])
  18. {
  19. int n;
  20. cin >> n;
  21. cout << sum(n)<<endl;
  22. system("pause");
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement