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