Advertisement
Pappu19

Factorial

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