I\'ve a very long factorial program which needs to find factorial up to 100. It works well up to 33 factorial but not from 34. Can someone help in identifying the problem.>
Problem is when carry > 10, then you insert one integer value without splitting it into chars, it should be implemented as follows
if(carry)
{
if (carry >= 10)
{
while (carry > 0)
{
v.insert(v.begin(),carry % 10); // put each char from carry into v
carry = carry / 10;
}
}
else
v.insert (v.begin(),carry);
}
with this you can even keep v
as vector
and for 50! we have
30414093201713378043612608166064768844377641568960512000000000000.