Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- // wersja "profesjonalna":
- unsigned suma_dzielnikow_wlasciwych(unsigned n)
- {
- if (n == 1)
- return 0;
- unsigned suma = 1;
- unsigned i;
- for(i = 2; i * i < n; ++i)
- if (n % i == 0)
- suma += (i + n / i);
- if (i * i == n)
- suma += i;
- return suma;
- }
- int main()
- {
- cout << suma_dzielnikow_wlasciwych(999999999) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement