Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int fac(int n) {
- if (n == 0) {
- return 1;
- }
- return fac(n-1) * n;
- }
- int main() {
- cout << "Enter n: ";
- int n;
- cin >> n;
- int result = fac(n);
- cout << "Factorial of " << n << " is " << result;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement