999ms

Untitled

Oct 1st, 2020
803
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int x;
  7.     cin >> x;
  8.     while (x >= 10) {
  9.         int ans = 0;
  10.         while (x > 0) {
  11.             ans += x % 10;
  12.             x /= 10;
  13.         }
  14.         x = ans;
  15.     }
  16.     cout << x << '\n';
  17. }
  18.  
RAW Paste Data