grigory51

Factorial

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