I made program take number from user then display the factorial of this number >>>> The program works well but if I enter 20 it crashes. I need help how to accept big number in my program ??????
This my program

#include<iostream>
using namespace std ; 
long long Fact(long long Num)
{
	string Number ;
	if(Num==1)
		return Num ; 
	return Num*Fact(Num-1) ;
}
int main()
{
	long long n,Num ; 
	cin>>Num ; 
	Num=Fact(Num) ;
	cout<<Num<<endl;
	return 0 ;
}

Thanks in advance :)

Recommended Answers

All 4 Replies

Look up some information about BigNums.
An integer or long integer can only hold a vast amount of bits.

How to get information about big nums can you help me with searching...
thanks in advance ...

Do you know that 70! is a number with ~100 digits, 450! has more than 1000 digits and so on...
Are you sure that anybody thirsts for reading these huge numbers printed on console?..
Apropos, what for string Number was declared in Fact function?..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.