#include "iostream"
using namespace std;
void main() {
int n;
cout << "Enter a positive integer: ";
cin >> n;
int factorial =1;
for(int i = 1; i <=n ; i++)
{
factorial = factorial * i;
}
cout << "Factorial of " << n << " = " << factorial;
}
Output
using namespace std;
void main() {
int n;
cout << "Enter a positive integer: ";
cin >> n;
int factorial =1;
for(int i = 1; i <=n ; i++)
{
factorial = factorial * i;
}
cout << "Factorial of " << n << " = " << factorial;
}
Enter a positive integer: 5
Factorial of 5 = 120
Factorial of 5 = 120
0 Comments
if you have any doubt in programming concept please let me know