# Last 10000 digits of Graham's number

So, if you didn't know, it's possible to compute the last $n$ digits of the Graham's number quite easily, by observing the fact that

$3\uparrow3=...7$,

$3\uparrow3\uparrow3=...87$,

$3\uparrow3\uparrow3\uparrow3=...387$,

$3\uparrow3\uparrow3\uparrow3\uparrow3=...5387$, and so on.

In fact, if you search on the internet you'll find several people that computed up to $200$ digits, $400$ digits, or $500$ digits.

Now, I admit I was pretty disappointed with this results. I couldn't find anyone that pushed up the calculations! (I may be wrong, in that case show me if anyone else actually calculated more than that)

So, I developed an algorithm that is sufficiently efficient to compute the first $500$ digits in only approximately $2$ seconds. With this algorithm, I was able to compute the last $10000$ digits of Graham's number on my computer, in $16316.5$ seconds (approximately $2.2$ hours).

I'm not entirely sure how, but I'm pretty sure it's possible to make the algorithm much more efficient than that, so that even calculating these digits should happen in a matter of few seconds. If you have any good ideas, tell me below (try it first, if possible).

Either way, here they are (new line every 70 digits):

$g_{64} = ...3078726077030301309631860565499591166728394144521822940211684925744690\\ 8303160862621307856182261004203129683467872420025335707165042882886038\\ 1527890583177734743488999363221709377188705302161340082623104165260987\\ 2469522381180520893701095105746695201447806881045566940953003050207963\\ 0251089314581777820684968377573229456578469591751099452615715258153133\\ 8317144176357246277980971517349406785579279353063617993752257361282030\\ 1473864489406090828511196812234883812826536412935235758505566522273299\\ 8513867089855758447648371115779454007188631486534611854130768464954083\\ 8335805841695412280766038020711553526827091695879475106425076890327782\\ 6708848390877435531688133831988779505683625673270427786212688069705881\\ 0276174028639378952134276596828174174610570754797760763975177038244691\\ 2063024310915173151554672020720329805779214569991795690518659602446902\\ 7274217279141430415867319657287140268008652315291316261820652195021921\\ 0914610704519073926283967434339662068326819744974641935341502976180597\\ 5219746989916790553951240749624022306775365113200227817050284227367149\\ 7491794032802699070161003317178855043208655046184676579497958334888729\\ 3809617659827235067373513656241299335615924204033665860263764635136445\\ 0901965169912468031701035813068048871232519853582991620638263170147783\\ 2698324585503287762867838791720029901423547073086007824609234282758224\\ 9084362130009203937656462657958086964494023780323916935845145868457435\\ 0019308749993296237589317856219609033942624384808517627658437282947072\\ 8254599948415970659821958864982353541909598033354078979538256357245359\\ 7473687377205449098623941105789048433603977408157821289037966848053431\\ 0161245447459165410165069396137727188277544585197396781572979626659473\\ 8946097169571922151724219229759670392571616731391424780277194256133384\\ 1909070301383939429023145632838588124976137279502774086096179244679618\\ 6025376358215497336320381116685826498270685734807990885455869123699181\\ 9878323695993552951130721247635787520841764173839071101104122258672751\\ 9228928871964307453282154261444871750080952421236363768139610777495235\\ 3201683350142428109136897852904313178813533335511088902235947721071584\\ 9496037260619984908856098462387682166967457951388588832356929998573679\\ 5420111111854634404435045676794013567654575959588995123046187234360352\\ 1793889196205026750886423489731195416265541685656346013519486952120940\\ 3751415314099407271948277374441254695053697070411390864858720859625554\\ 1959030238060629137169138722855477794398025076773239670591720768747467\\ 2844654063418138034129430436097660215542336711205739081742346117574411\\ 8240134002338774237104408010940301648706232749183781478765763754598101\\ 5382140877149223264515258326901107991667754434423538374815474031008806\\ 3794659755273784075854629840335173116218238312437640446823996561592082\\ 8447876334410730503146643034564958892386400206720157774336643971046097\\ 1913397786711927076109359761269701118640088324214111573518542523175301\\ 8437333602444678510859228109479432808176387274946992467944754462151350\\ 5367844082852088230997958080227897832298874619826542016735413058821008\\ 1847428327743235541621704680913967417772759547636593847461261352062528\\ 6493615579933087865883727503023169846062624381686315823768546266806694\\ 4052359344981816230189301309354006700248433587219900315863936527371581\\ 9660118267438193855827192236488406202498847093959194410120314045227731\\ 5157935152536936493425053093270987737803549232774078167979402086740138\\ 2441063153368792024085513096521839198783970159526194524749783176345096\\ 6138354215340807779927410436230549205899966191897479395002808032068505\\ 2798877144984365085442674905448699279843309239159997374495902995758836\\ 3427364161563026748153852589303542350028921428192299937990553925840346\\ 3179740764550809001835012576720025421347754368577841258214793482088528\\ 3528473446395144549774006915475700147362629356396411599745063763259120\\ 7602085065331518191297627524916528283327470445487220431209794181800837\\ 5242881807867409536257070239161286255743400994204946286838833646124751\\ 9450140740102350858410502955539960188235779958081190441955895515413996\\ 2907362641416032599108674402147606737302706859009869989241966114092477\\ 2407789976751585993614061850356986544196252382034927589676238991215557\\ 8594439247420428277018540432967913180650401616546821719644550936450059\\ 5583090752015617577969861470976788938740200600298288287888330891308863\\ 3722819728625451800838400216724842196639874673295077669833180844718217\\ 9341171005320299673923404289980856827543457807278033622507455463530345\\ 2502047026773318085940276837031308524437227254648631365299090852540852\\ 7368117005989256614980159639267250074517606853740135934062100746075654\\ 0813896593247352620824016619700186551382187297721949846316900749082737\\ 8094264056082839271636552848839603826288292359895120699259424392975074\\ 9821816437833463246454551763732757655276760590582693972496924532998092\\ 3380190551831802463416887618541048817756223855531234022957969144122483\\ 6406466849925916755964304671002296817244339224792182135995868969341492\\ 3690776243056770164822502041983470306716296896922618604046908954485889\\ 1348275274667315520855871416643581761678324893080737347771500148013131\\ 5872093173217027881014846523723198056977435033203823397583204572679056\\ 6651633842068281545694928486633422445461995837450720456764508778883440\\ 3854173232861131892325939242549724454004862230630447361306160309037871\\ 5800584480793579521136958705250576661572845777934961160672813467687918\\ 2468219518101142821666186785543970961610009398295493882433280467468806\\ 9413764541931265604057917863711717794304584231021596233589764804054811\\ 8226228812074485140806951381912453398593093071760684032101862850540079\\ 7648371363380891593720550471092872187099316006161890897978303030444170\\ 7453650131619894698610993458668339554364084020023399067051642966934860\\ 0027570319308957395061221345848777985085039705997484485916440720079353\\ 6749317556015986374673052074784015605376345910038695996792166640248506\\ 5151972178292734011493177498161942761055395341214573854386960142347615\\ 1064120816786711566627026981412394927353467365863136279136411085250120\\ 5029022957845553710087982096902106709311969126401168909948606316616230\\ 2923902195299675526555986392068330814711696071435279166352601845751091\\ 1413391101513558310051637274156744456218580403883246348766716791121059\\ 6640361544098108142733814394129952702989282677057681983318348451157632\\ 3445763461588558180723948837731724171820914217827456505430234904693165\\ 7016237345668584450386474453301178678720075637289970867637583657220506\\ 2491301610433455913955841065225929205594669325571087621309871185323210\\ 5196699704725638064513028255040447297723752850180331481056404968157353\\ 9061785278598760313140865068530080919200003079350549373708348792972286\\ 8670573755820995979960622710931298072888031118784826564331478394544516\\ 8149803763580948273619215580715203535826455618889996767810934669730243\\ 5416969251647217062623523969036088524240889973797522976568651221236460\\ 6700882735550252805162688717743002242430178153096139879227557097022144\\ 3057790329335567051650934703248833671211260215491243781456055632180252\\ 2593943710111389180996687955300606304861015768885793044484950849027511\\ 0106029803619475963780866084863862122324538632723342196159851036070658\\ 3695251304412583544807924551217328349121977645145493850412041271265386\\ 4611628171304512992288612473168928694708607916093810579534245595047488\\ 6617927058056116386911212141737555332931772421804354502689741745136461\\ 9149258184608873236073683901075275381240402732984629660210771321778593\\ 5317908316720145478172167767818370069254396358778477381821832282338662\\ 9557597665763526037469623882734970261718460508041643967446394822226604\\ 7262800922130068469037144793383117028262382841196033782589178075561744\\ 9686306276313945559616369461957875659406855496062664521105020034463607\\ 8639152176612841273246755062872676148243079798928244275312027774818688\\ 7250109520756590181937968438911972868200142926836525620315535316031054\\ 6891685301933822474738169794305170907203165619769535061113213915856256\\ 1824661400448048835400453257011706951826263434793588413474586938545913\\ 1913595602946034912375719564262285371586081255164508962613460090798485\\ 7847797205307145186514675412317888384738009343344165376733605639874152\\ 6838837135702194865074959666167436192933645884998056100697104793100679\\ 4152084453613830911021630017437654919684883920437258419601503784784516\\ 0671512017198801157547084883939593053650556078872159994750221442214834\\ 8268144787270731001365537383577746098505866012640076129423352326255313\\ 3073942052007839547749762554111899859772880815945865752809988634672233\\ 4769804780146302789353612329312586963866559329949214911489134763214665\\ 4314303272656947761889503867538372033508034358690038674211367316517236\\ 2113256247997506770294235705056911305065974352655256553654276889526636\\ 0391135992668989734244822601493574507744556050638326609473542254360350\\ 8674855342484610627305685534794791282019520577643564769466316663822950\\ 0048280051827615363513800094323248679021061702425944029209484941954536\\ 7418064519308105163357496871638118822504114501587037019405680648005022\\ 5768533805530305183368091271811490817539484300268084104379556148104831\\ 5835447210850384076723823375354333111031697890169996590703687564769571\\ 4199517294684058268271081207938885760678089057660597351282040660918730\\ 7108483992113117957918089160673029776868734932638038255189701221105348\\ 1886141584874851920098526106525203948232207371149341083916873785440379\\ 8603368448472052729248390757866617805529414157119366603081892881936678\\ 7741482317801728126934985735783270950758576591974947039193152967596669\\ 2340488030236244704910353178090822611674695077464191287728244330583239\\ 5092525499355092526168572459565741317934416750148502425950695064738395\\ 6574791365193517983345353625214300354012602677162267216041981065226316\\ 9355188780388144831406525261687850955526460510711720009970929124954437\\ 8887496062882911725063001303622934916080254594614945788714278323508292\\ 4210209182589675356043086993801689249889268099510169055919951195027887\\ 1783083701834023647454888222216157322801013297450927344594504343300901\\ 0969280253527518332898844615089404248265018193851562535796399618993967\\ 905496638003222348723967018485186439059104575627262464195387$

Note by Aldo Roberto Pessolano
1 year ago

This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.

When posting on Brilliant:

• Use the emojis to react to an explanation, whether you're congratulating a job well done , or just really confused .
• Ask specific questions about the challenge or the steps in somebody's explanation. Well-posed questions can add a lot to the discussion, but posting "I don't understand!" doesn't help anyone.
• Try to contribute something new to the discussion, whether it is an extension, generalization or other idea related to the challenge.

MarkdownAppears as
*italics* or _italics_ italics
**bold** or __bold__ bold
- bulleted- list
• bulleted
• list
1. numbered2. list
1. numbered
2. list
Note: you must add a full line of space before and after lists for them to show up correctly
paragraph 1paragraph 2

paragraph 1

paragraph 2

[example link](https://brilliant.org)example link
> This is a quote
This is a quote
    # I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
# I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
MathAppears as
Remember to wrap math in $$ ... $$ or $ ... $ to ensure proper formatting.
2 \times 3 $2 \times 3$
2^{34} $2^{34}$
a_{i-1} $a_{i-1}$
\frac{2}{3} $\frac{2}{3}$
\sqrt{2} $\sqrt{2}$
\sum_{i=1}^3 $\sum_{i=1}^3$
\sin \theta $\sin \theta$
\boxed{123} $\boxed{123}$

Sort by:

Update: I just found a site that lists exactly the same digits, so I'm definitely not the first to have calculated this digits. Still, the efficiency question remains.

what's the algorithm?

- 11 months, 3 weeks ago

The most efficient algorithm I thought for now is just one line on Mathematica:

calc = 3; Do[calc = PowerMod[3, calc, 10^i], {i, 1, 500}]; calc

This computes the latest 500 digits correctly in roughly 0.7 seconds on my computer. For 1000 digits, it takes 6.2 seconds. The main problem with this algorithm is that it gets progressively much slower since it computes all the already computed digits with every calculation. There must be a way to avoid recomputing all the digits every time, for example to get the 1001st digit pretty much instantly just by knowing the latest 1000 digits, but I can't quite figure out how.

- 11 months, 3 weeks ago

Testing Math Editor: $\pi$

- 11 months ago

Booya! $e^{i \pi} +1 = 0$

- 11 months ago

hi

- 11 months, 3 weeks ago