Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int fact(int);
- void main()
- {
- int n;
- cout << "This program calculates n! . \n"
- << "n = ";
- cin >> n;
- cout << fact(n) << endl;
- }
- int fact(int b)
- {
- if (b < 0)
- return 1;
- else
- return b * fact(b - 1);
- }
Add Comment
Please, Sign In to add comment