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);
}




1 comment:

  1. Hey, I also have a very interesting program to calculate the factorial of any number, no matters whether the number is very large, like if you wish to calculate the factorial of 500, my program will calculate it, and even it gives each and every digit of the result. for details and source code visit http://codingloverlavi.blogspot.in/2013/03/here-is-one-more-interesting-program.html
    hope you would like it.
    You can find some other simple programs for factorial on the following links:-
    http://codingloverlavi.blogspot.in/2013/05/recursive-program-for-factorial.html
    http://codingloverlavi.blogspot.in/2013/05/factorial-calculation-without-any.html

    ReplyDelete

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