Twist_Nemo

small_factorials.cpp

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