Advertisement
dllbridge

Untitled

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