Need a project done?

C++ Programming Developer

Search This Blog

Factorial Calculator

Calculate Factorial C++:
Factorial Calculator Program in C++:

#include <iostream>
using namespace std;

int main()
{
//Factorial Calculator
int N;
cout<<"Factorial of ";
cin >> N;
int Num = 1;
for (int i=1; i<=N; i++)
Num *= i;
cout<<"Factorial is "<<Num<<endl;
}

//==================================================================================

//Smaller code for calculating factorial.

#include <iostream>
using namespace std;
factorial(int);

int main()
{
//Factorial Calculator
int N;
cout<<"Factorial of ";
cin >> N;
cout << "Factorial: " << factorial(N);
}

inline factorial(int n)
{
return (n < 2) ? 1 :  n * factorial(n-1);
}




"Don't let anyone ever make you feel like you don't deserve what you want."