Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- //Zad11
- using namespace std;
- int n;
- int SILNIA(int n)
- {
- if (n<2)
- {
- return n;
- }
- else
- {
- return n*SILNIA(n-1);
- }
- }
- int main()
- {
- cout << "Podaj liczbe: " << endl;
- cin >> n;
- if (n<1)
- {
- cout << "To nie jest liczba naturalna!" << endl;
- }
- else
- {
- cout << "Silnia z tej liczby to: " << SILNIA(n) << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment