Advertisement
Guest User

Untitled

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