MarcinKrol

Zad11

Mar 24th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3.  
  4. //Zad11
  5.  
  6.  
  7. using namespace std;
  8.  
  9. int n;
  10.  
  11. int SILNIA(int n)
  12. {
  13.  
  14. if (n<2)
  15. {
  16. return n;
  17. }
  18.  
  19. else
  20. {
  21. return n*SILNIA(n-1);
  22. }
  23. }
  24.  
  25.  
  26. int main()
  27. {
  28. cout << "Podaj liczbe: " << endl;
  29. cin >> n;
  30. if (n<1)
  31. {
  32. cout << "To nie jest liczba naturalna!" << endl;
  33. }
  34. else
  35. {
  36. cout << "Silnia z tej liczby to: " << SILNIA(n) << endl;
  37. }
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment