Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NEED HELP WITH FACTORIALS !!!

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0


Can anyone help me to find the largest VALUE of N for which N!(factorial of N) has fewer than 100 (decimal digits) and fewer than 1000 (decimal digits) ?
 
69! =
171,122,452,428,141,311,372,468,338,881,272,839,092,270,544,893,520,369,393,648,040,923,257,279,754,140,647,424,000,000,000,000,000

(99 digits)

and

449! = 38,519,305,180,280,725,763,215,847,691,212,875,548,395,805,893,534,467,012,649,055,767,896,288,926,298,594,457,881,668,628,676,415,791,435,136,187,818,720,217,463,596,852,902,892,556,018,549,547,069,670,372,378,159,819,334,271,735,471,638,382,734,807,840,186,751,249,583,042,983,720,300,081,355,781,130,751,601,099,935,399,420,025,859,541,702,588,941,624,119,769,786,447,979,635,875,887,987,628,187,121,141,743,814,227,340,405,786,877,075,540,700,136,227,919,818,634,007,425,579,126,136,583,156,012,933,348,747,449,102,149,815,962,647,863,834,705,576,714,179,015,069,575,989,844,000,509,497,340,761,230,129,254,648,880,664,249,707,996,772,824,842,574,358,558,533,486,456,993,617,018,144,080,838,058,452,833,163,022,395,716,238,804,463,454,122,374,136,551,392,458,402,546,135,467,775,972,918,729,773,166,312,427,787,861,887,749,833,467,752,180,081,269,884,348,992,863,634,984,303,810,255,947,153,663,266,095,784,399,888,312,698,855,788,258,154,809,005,327,539,117,440,908,208,905,353,330,891,394,428,678,158,921,052,069,748,074,205,537,868,136,717,094,006,764,031,023,426,591,318,276,097,353,833,638,375,226,039,787,340,475,684,974,328,746,914,841,262,748,828,969,418,676,947,795,312,640,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000

(998 digits)


The start off point for small calculations is something like:

n = factorial.
<type>j = 1;
for (INT i = 1; i <= n; ++i)
{ j = j*(i+1);
blah blah...
}
leaving j with the result.
You will need to wrap the above into a suitable data structure for larger factorials ( I used an integer array ).

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top