Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int sumac (int n)
- {
- int s=0;
- while (n>0)
- {
- s=s+n%10;
- n=n/10;
- }
- return s;
- }
- int f(long long n)
- {
- while (n>9)
- {
- n=sumac(n);
- }
- return n;
- }
- int main()
- {
- long long n;
- cin>>n;
- cout<<f(n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement