C++ program to Calculate Factorial of a Number Using Recursion
Source Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include<iostream> using namespace std; int factorial(int n); int main() { int n; cout << "Enter a positive integer: "; cin >> n; cout << "Factorial of " << n << " = " << factorial(n); return 0; } int factorial(int n) { if(n > 1) return n * factorial(n - 1); else return 1; } |

Post a Comment
Click to see the code!
To insert emoticon you must added at least one space before the code.