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