The Factorials

In this article, we will cover the factorials, numbers that are the products of consecutive integers starting with 1, as well as their properties.

Below are the first factorials of integers.

1! = 1

2! = 1*2 = 2

3! = 1*2*3 = 6

4! = 1*2*3*4 = 24

5! = 1*2*3*4*5 = 120

6! = 1*2*3*4*5*6 = 720

7! = 1*2*3*4*5*6*7 = 5040

8! = 1*2*3*4*5*6*7*8 = 40320

9! = 1*2*3*4*5*6*7*8*9 = 362880

10! = 1*2*3*4*5*6*7*8*9*10 = 3628800

11! = 1*2*3*4*5*6*7*8*9*10*11 = 39916800

12! = 1*2*3*4*5*6*7*8*9*10*11*12 = 479001600

13! = 1*2*3*4*5*6*7*8*9*10*11*12*13 = 6227020800

The factorials have the following significance in combinatorics: n! is equal to the number of ways of arranging n objects. For example, there are 6 ways of arranging 3 objects:

A B C

A C B

B A C

B C A

C A B

C B A

The number of ways of shuffling a deck of cards is 52!, which is approximately 8.065817517*10^67, so when you shuffle a deck of cards, it is overwhelmingly likely that no one has ever had this exact order before.

Coincidentally, there are 4! hours in a day, and 10! seconds in 6 weeks. There are 8! minutes in February of a non-leap year. And, a day is the same as 6! intervals of 2 minutes.

Below are the values of selected larger factorials.

14! = 87178291200

15! = 1307674368000

20! = 2432902008176640000

25! = 15511210043330985984000000

30! = 265252859812191058636308480000000

70! = 11978571669969891796072783721689098736458938142546425857555362864628009582789845319680000000000000000

100! = 93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000

The first factorial to be greater than a googol is 70! (which is also the first factorial that is too big for pocket calculators using 2-digit exponents), and 170! is the largest factorial that can be represented in the IEEE double-precision floating-point format. 3248! is the largest factorial that can be calculated on the Windows calculator, which overflows just under a googoltoll (10^10000).

The reciprocals of the integer factorials sum to to the mathematical constant e:

1/1 + 1/2 + 1/6 + 1/24 + 1/120 + 1/720 + 1/5040 + 1/40320 + ... = 2.718281828459045235360287...

It appears that if we go further out in the sequence of integer factorials, the number of trailing zeroes increases. In fact, the number of trailing zeroes in n! is the sum of floor(n/5^k) for all values of k (eventually this will become 0, so once the result becomes constant you have the number of trailing zeroes in the factorial of the number). The sudden jump from four trailing zeroes to six trailing zeroes from 24! to 25! is because 25 has two 5 factors, not just one. The same happens at 50!, 75!, 100!, and at 125!, three trailing zeroes are added.

The number of times n! is divisible by a certain prime p is computed in a similar way, and comes out to be almost n/(p-1). For example, the number of 2s in n! is almost n, and the number of 3s in n! is approximately n/2, which is also approximately the number of times n! can be divided by 4 without leaving any remainder.

The factorial of 100 has 24 trailing zeroes because 24 is the result of the above for 100, and there is always an excess of 2s over 5s in the factorization of a factorial.

The factorial of 0 is actually equal to 1, even though many people who have not learned that think it is 0 (I myself thought it was 0 until I learned it was 1 while doing these problems on an educational site in October of 2013, a few months before I started getting interested in numbers for the first time). This can be proven because n! = (n+1)!/n+1, and so 0! is equal to 1!/1 which is 1/1 or 1. However, (-1)! is where problems arise, as (-1)! would be 0!/0 = 1/0.

Nesting the factorial function can give you way larger numbers. For example, ((3!)!)! evaluates to 720!. Its decimal expansion is below.

2601218943565795100204903227081043611191521875016945785727541837850835631156947382240678577958130457082619920575892247259536641565162052015873791984587740832529105244690388811884123764341191951045505346658616243271940197113909845536727278537099345629855586719369774070003700430783758997420676784016967207846280629229032107161669867260548988445514257193985499448939594496064045132362140265986193073249369770477606067680670176491669403034819961881455625195592566918830825514942947596537274845624628824234526597789737740896466553992435928786212515967483220976029505696699927284670563747137533019248313587076125412683415860129447566011455420749589952563543068288634631084965650682771552996256790845235702552186222358130016700834523443236821935793184701956510729781804354173890560727428048583995919729021726612291298420516067579036232337699453964191475175567557695392233803056825308599977441675784352815913461340394604901269542028838347101363733824484506660093348484440711931292537694657354337375724772230181534032647177531984537341478674327048457983786618703257405938924215709695994630557521063203263493209220738320923356309923267504401701760572026010829288042335606643089888710297380797578013056049576342838683057190662205291174822510536697756603029574043387983471518552602805333866357139101046336419769097397432285994219837046979109956303389604675889865795711176566670039156748153115943980043625399399731203066490601325311304719028898491856203766669164468791125249193754425845895000311561682974304641142538074897281723375955380661719801404677935614793635266265683339509760000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

The double factorial of a number is equal to the product of all odd numbers up to that number if the number is odd, or the product of all even numbers up to that number if it is even. Below are the first double factorials of odd numbers.

1!! = 1

3!! = 1*3 = 3

5!! = 1*3*5 = 15

7!! = 1*3*5*7 = 105

9!! = 1*3*5*7*9 = 945

11!! = 1*3*5*7*9*11 = 10395

13!! = 1*3*5*7*9*11*13 = 135135

15!! = 1*3*5*7*9*11*13*15 = 2027025

17!! = 1*3*5*7*9*11*13*15*17 = 34459425

19!! = 1*3*5*7*9*11*13*15*17*19 = 654729075

21!! = 1*3*5*7*9*11*13*15*17*19*21 = 13749310575

23!! = 1*3*5*7*9*11*13*15*17*19*21*23 = 316234143225

25!! = 1*3*5*7*9*11*13*15*17*19*21*23*25 = 7905853580625

27!! = 1*3*5*7*9*11*13*15*17*19*21*23*25*27 = 213458046676875

29!! = 1*3*5*7*9*11*13*15*17*19*21*23*25*27*29 = 6190283353629375

Below are the first double factorials of even numbers.

2!! = 2

4!! = 2*4 = 8

6!! = 2*4*6 = 48

8!! = 2*4*6*8 = 384

10!! = 2*4*6*8*10 = 3840

12!! = 2*4*6*8*10*12 = 46080

14!! = 2*4*6*8*10*12*14 = 645120

16!! = 2*4*6*8*10*12*14*16 = 10321920

18!! = 2*4*6*8*10*12*14*16*18 = 185794560

20!! = 2*4*6*8*10*12*14*16*18*20 = 3715891200

In either case, n!! is actually less than n!, contrary to the impression given by the double exclamation mark.

Googolbang

The googolbang is the factorial of a googol. At first, it seems impossible to compute exactly how many digits it has or how it begins, but it turns out that it can be done using high-precision methods to estimate the factorial. First, we will try to bound the number, and then find the more accurate value.

We will begin by noting that n! can never exceed n^(n-1), so we can prove that the googolbang is less than 10^((10^100 - 1)*100). And, n! overtakes 10^n at n = 25, and it overtakes 10^2n at n = 269, so the googolbang is greater than 10^(2*10^100). So, the bounds we have at this point are:

10^(2*10^100) <  googolbang < 10^((10^100 - 1)*100)

But we can do better by observing that (10^n)! is greater than 10^((10^n)*(n-1)): 10! is surely greater than 10^0 = 1, 100! is greater than 10100, 1000! is greater than 102000, and 10000! is greater than 1030000. This pattern continues: 100000! is greater than 10400000, 1000000! is greater than 105000000, and so on, which means that the googolbang is greater than 10^(99*10^100) or 10^(9.9*10^101). Not only have we proven that the number of digits in the googolbang has exactly 102 digits, but that the number of digits in the googolbang begins with 99:

10^(9.9*10^101) < googolbang < 10^(9.9999999...9999999*10^101) with 100 nines in the latter exponent

Now we can improve the upper bound in a similar way. 10! is greater than 10^6, but then 100! is less than 10^160, 1000! is less than 10^2600, and 10000! is less than 10^36000. In general, for any integer n > 1, (10^n)! is less than 10^((n-1)*10^n + 6*(10^(n-1))). For the lower bound, we can do the same, but replace the 6s with 5s, and so our best bounds are now:

10^(9.95*10^101) < googolbang < 10^(9.96*10^101)

The method most commonly used is Stirling's approximation, which is as follows:

n! ~ sqrt(2*pi*n)*(n/e)n

Using this, we obtain that the googolbang has

995,657,055,180,967,481,723,488,710,810,833,949,177,056,029,941,963,334,338,855,462,168,341,353,507,911,292,252,707,750,506,615,682,568 digits, and we can obtain 101 correct leading digits. The first digits of the googolbang are 1629404332459337.... Below are more first digits of the googolbang, which I calculated using even more precise approximations for large factorials.

1629404332459337373417934652983542172821888426714866230362361193694092202945250468667985447084223178922812948054982565155106826536915425196958987526109135317094717834070448069067901501631170379226749402082595963417110594103792879767463509493865752541061320855428593535914800002734036598748123687724424915920507720265380610530057032925356649646480347035468337570436200066961949218284720666660322882051527631545727198882294360006330057149512969124488388438678046774570297925865213821406213319524682349480101798926400099508165375138539784111728192154140678069669258122612825462694478043118400458557452826429258458370890299849278951002779946780330421830413418662212460540696792476613883307337002887742440075406233050100224489635316705952257077394446300568254516859232286819937780316605628712219582451811602331665844242665359734592642520737627199001318212740817690511757103927064581072408847887198710956474874176278189117956911231138123983562491914026932169022591051054089955565980760504055986096779959787927188879647793617673676966979328455609948800920043280294753196134314212481307990105004697568193101366659780143028453352232894872156830849908190183044916020963237244093781123561790818187911044824095500797169888124337253067096650902220674157986429106537614893420511038895616644087042908478780691154311260069107095390412732998841783100171775391905120575651141244224025019389587671367617953086467417650060527566697869422244214961296593752434992526148677781287901035681913206998521258178978654769016628079774251329123691548931370283025324314610307858557850574207919053202959495670134311895907735015542441133061829235174128279318085468680112434686475980594864927348641463698985496475562442577172483689127636143191062031600865042695321677408915049767195309412780080707196745947466805455422638430861781447344618985664837997459548004702014338387109610719841151526758342402956941053327075776516127769027778194...

The googolbang has exactly 2499999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999982 trailing zeroes, and the last 13 non-zero digits are ...5473738735616. No page I have seen gives any more than the last non-zero digit (but now mine has the last 13 which Wolfram Alpha gives, but as far as I know I am the first to include more than one of the last non-zero digits of the googolbang on a webpage).

I also defined the grand googolbang to be the product of the first googol factorials. Its leading digits are 1892485631488813561428212228905867993089552794656363427708208900757719113355551590280.... It has approximately 4.967428*10^201 digits.

Alternating factorials

The alternating factorial of a number is equal to 1! - 2! + 3! - 4! + ...  - (n-1)! + n! when n is odd, and -(1!) + 2!  - 3! + 4! + ...  -(n-1)! + n! when n is even. Below are the first alternating factorial numbers. af(n) can be shown to be equal to n! - af(n-1).

af(1) = 1

af(2) = 1

af(3) = 5

af(4) = 19

af(5) = 101

af(6) = 619

af(7) = 4421

af(8) = 35899

af(9) = 326981

af(10) = 3301819

af(11) = 36614981

af(12) = 442386619

af(13) = 5784634181

af(14) = 81393657019

af(15) = 1226280710981

And, below are selected larger alternating factorials.

af(20) = 2317323290554617019

af(25) = 14915538431227735068422981

af(30) = 256705485669535347568006115577019

af(35) = 10046343320261587490171853861825564422981

af(40) = 796027021978059135393314656928325779313635577019

af(50) = 29817972015629302995182567242334801579950768815528034161635577019

af(70) = 11809893318195492906423362422261723211461109491055454565957957813190913963268700251019362161635577019

af(100) = 924022849686494604510605352200668781892423600677834270180096086110429903925674108795527025991508900258869743754743057740256028905539428214465393621

61635577019

And, af(n+1) is equal to (n+1)! - af(n).

It appears that as we travel further along the sequence of alternating factorials, more last digits alternate between a sequence ending in ...981 and a sequence ending in ...019. That is, as we travel along the sequence of odd-indexed alternating factorials, the last digits converge, and the same for the even-indexed ones. Since all alternating factorials are odd, all doubly alternating factorials end in ...422981 (except for af(af(3)) = af(5) = 101)

The sum of the reciprocals of alternating factorials is the constant 2.26440551793253170629....

The first alternating factorial other than 1 that is composite is af(9) = 326981 = 79 x 4139. Eventually, however, alternating factorial primes become a novelty, and in fact there is a provable limit to alternating factorial primes. 3612703 divides af(3612702), and since 3612703! is surely divisible by 3612703, 3612703! - af(3612702) = af(3612703) is also divisible by 3612703. The same is true for all higher alternating factorials.

The alternating googolbang is equal to af(10100). Its number of digits and first 100 digits are the same as those of the googolbang, and its last digits are ...236758821446539362161635577019. The first digits in the number after the 1629404332459337...447084223178 (or the first 100 digits) are 75987251480904.... Below are more first digits of the alternating googolbang.

16294043324593373734179346529835421728218884267148662303623611936940922029452504686679854470842231787598725148090488278133133612385612079147701448546225122808...