Advertisement
PiotrSzewczyk

Zad 11

Mar 31st, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int silnia (int n)
  5. {
  6.     if (n<2){
  7.        return n;
  8.     }
  9.     else {
  10.         return n*silnia(n-1);
  11.     }
  12. }
  13.  
  14. int main()
  15. {
  16.     int liczba;
  17.     cout << "podaj liczbe: " << endl;
  18.     cin >> liczba;
  19.     cout << silnia(liczba) << endl;
  20.     return(0);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement