I would like to find a 100!
I wrote the program below. However using decimal would give me it in decimal form and I would like it in integer for as this site gives it
http://www.numberempire.com/factorialcalculator.php
ans=933262154439441526816992388562667004907159682643816214685929
638952175999932299156089414639761565182862536979208272237582
51185210916864000000000000000000000000
How do I do that . Any help would be greatly appreciated.
# include <iostream>
# include <sstream>
#include <stdlib.h>
using namespace std;
long double facto(long double a, long double result)
{
if (a==0){return result;}
result = result*a;
if (a>0)
{return facto(a-1,result);}
}
int main()
{
while(1){
long double num,ans; string end;
cout<<"\nPlease enter the number you wish to find the factorial of.\n";
cin>>num;
if(num<0)
{
cout<<"\nThis is not a valid number.\nPlease enter a number greater than 0\n";
}
ans=facto(num,1);
cout<<"\nThe factorial of "<<num<<" is: "<<ans<<"\n\n";
cout<<"\nWould you like to quit?<y for Yes,\nTo clear the screen and continue using the program type capital N\nPress any other key to continue without clearing the screen.>\n";
cin>>end;
if(end=="y"||end=="Y")
{
cout<<"\nThankyou for using Kevin Ramsook's Factorial Calculator\n";
system ("pause");
return 0;
}
if(end=="N")
{ system ("cls");}
}
return 0;
}