Factorial of a large no. using C++

How to find the facorial of a large no. like that of 100 using C++.
Especially how to store the vvalue of 100!.

here :smiley:

1 Like

You can visit as below : -
http://discuss.codechef.com/questions/7349/computing-factorials-of-a-huge-number-in-cc-a-tutorial

OR

0

Bellow is the simple logic for computing factorial

include< iostream>

include< conio.h>

using namespace std;

void main()

{

int i,f=1,n;

scanf("%d",&n);

for(i=1;i<=n;i++)

{

f*=i;

}

printf("%d\n",f);

getch();

}

@namankumar

Avoid using conio.h header file and associated functions that are getch() and clrscr().

Also this logic fails for computing factorial of 100 as factorial(100) is

93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000L

Go through with this tutorial, given by @kuruma

http://discuss.codechef.com/questions/7349/computing-factorials-of-a-huge-number-in-cc-a-tutorial

Here a nice explanation for how to calculate factorial of a large number in C/C++ is given, read and try to implement by yourself. Tutorial is really interesting

1 Like

Thanks for correcting me!

1 Like