Advertisement
RadioNurshat

MultiFactorial

Sep 30th, 2020
1,067
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.24 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. using namespace std;
  4. int main()
  5. {
  6.     int n;
  7.     int nn = 1;
  8.     int i = 0;
  9.     cin >> n;
  10.     if (n % 2 == 0) {
  11.          i = 2;
  12.     }
  13.     else {
  14.         i = 1;
  15.     }
  16.     while (nn < n) {
  17.         nn = nn * i;
  18.         i += 2;
  19.     }
  20.     cout << nn << endl;
  21. }
  22.  
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement