Advertisement
DMG

Teorema 153

DMG
Jul 2nd, 2012
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int clan (int n)
  5. {
  6.     int p = 0;
  7.     while (n>0)
  8.     {
  9.           p = p + (n%10)*(n%10)*(n%10);
  10.           n = n / 10;
  11.     }
  12.    
  13.     return p;
  14. }
  15.  
  16. main()
  17. {
  18.       int a, s=1;
  19.      
  20.       cout << "Unesite broj djeljiv sa 3: ";
  21.       cin >> a;
  22.      
  23.       while (a!=153)
  24.       {
  25.             a = clan(a);
  26.             s++;
  27.       }
  28.      
  29.       cout << "Posle " << s << " koraka pojavio se broj 153 u nizu!" << endl;
  30.      
  31.       system ("PAUSE");
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement