Advertisement
olaaa

Untitled

Nov 4th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int silnia(int n)
  4. {
  5. int suma;
  6. if (n == 1)
  7. {
  8. return 1;
  9. }
  10.  
  11. if (suma = n * silnia(n - 1))
  12. {
  13. return suma;
  14. }
  15. else
  16. {
  17. return 0;
  18. }
  19.  
  20.  
  21. }
  22. int main()
  23. {
  24. int n, wynik;
  25.  
  26. cin >> n;
  27.  
  28. wynik = silnia(n);
  29. cout << wynik << endl;
  30.  
  31.  
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement