Advertisement
Josif_tepe

Untitled

Mar 18th, 2021
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.24 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int factorial(int x) {
  6.     if(x == 1) {
  7.         return 1;
  8.     }
  9.     return factorial(x - 1) * x;
  10. }
  11. int main()
  12. {
  13.     int n;
  14.     cin >> n;
  15.     cout << factorial(n) << endl;
  16.     return 0;
  17. }
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement