Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int x;
- cin >> x;
- while (x >= 10) {
- int ans = 0;
- while (x > 0) {
- ans += x % 10;
- x /= 10;
- }
- x = ans;
- }
- cout << x << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement