Advertisement
Guest User

factorial.cxx

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