Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main() {
- int p, n;
- cin >> p >> n;
- for(int i = 0; i < n; i++) {
- int tmp = p;
- int sum = 0;
- while(tmp > 0) {
- int cifra = tmp % 10;
- cifra *= cifra;
- sum += cifra;
- tmp /= 10;
- }
- p = sum;
- }
- cout << p << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement