Advertisement
sazid_iiuc

Untitled

May 20th, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. //Find factorial of a number
  2.  
  3. #include<bits/stdc++.h>
  4. using namespace std;
  5.  
  6. unsigned long long int factorial(unsigned int number)
  7. {
  8.     if(number<=1)
  9.     {
  10.         return 1;
  11.     }
  12.     unsigned long long int output= number * factorial(number -1);
  13.  
  14.     return output;
  15. }
  16.  
  17. int main()
  18. {
  19.     int input;
  20.     cin>>input;
  21.  
  22.     cout<<factorial(input);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement