Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- unsigned long long fact(unsigned x)
- {
- if (!x)
- return 1;
- return fact(x - 1) * x;
- }
- unsigned get_sumdiv(unsigned x, unsigned sumdiv)
- {
- if (sumdiv == 1)
- return 0;
- if (x % sumdiv == 0)
- return get_sumdiv(x, sumdiv - 1) + sumdiv;
- return get_sumdiv(x, sumdiv - 1);
- }
- unsigned get_sumcif(unsigned x)
- {
- if (!x)
- return 0;
- return get_sumcif(x / 10) + (x % 10);
- }
- unsigned get_prodcif(unsigned x)
- {
- if (!x)
- return 1;
- return get_prodcif(x / 10) * (x % 10);
- }
- void read(unsigned n)
- {
- if (n)
- {
- unsigned x;
- cin >> x;
- cout << "fact: " << fact(x) << '\n';
- unsigned sumdiv = get_sumdiv(x, x / 2);
- cout << "sumdiv: " << sumdiv << '\n';
- if (sumdiv + 1 != x)
- cout << "nu ";
- cout << "e perfect" << '\n';
- cout << "sumacif: " << get_sumcif(x) << '\n' << "prodcif: " << get_prodcif(x) << '\n';
- read(n - 1);
- }
- }
- int main()
- {
- unsigned n;
- cin >> n;
- read(n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement