Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int mocninkovac (int a)
- {
- int soucet = 0;
- int cifra =0;
- while (a>0)
- {
- cifra = a%10;
- a= a/10;
- soucet = soucet + cifra*cifra;
- }
- return soucet;
- }
- bool zadovac (int cislo)
- {
- while (cislo != 1 && cislo != 89)
- {
- cislo = mocninkovac(cislo);
- }
- if (cislo == 89)
- {
- return true;
- }
- return false;
- }
- int main()
- {
- int pocet = 0;
- for (int a = 1; a <= 10000000; a++)
- {
- if (zadovac(a))
- {
- pocet++;
- }
- }
- cout << "Hello World!" << endl;
- cout << pocet << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement