Advertisement
Guest User

Untitled

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