Guest User

Untitled

a guest
May 20th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.27 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int fact(int);
  5.  
  6. void main()
  7. {
  8.     int n;
  9.     cout << "This program calculates  n! . \n"
  10.          << "n = ";
  11.     cin >> n;
  12.  
  13.     cout << fact(n) << endl;
  14. }
  15.  
  16. int fact(int b)
  17. {
  18.     if (b < 0)
  19.         return 1;
  20.     else
  21.         return b * fact(b - 1);
  22. }
Add Comment
Please, Sign In to add comment