# Largest Prime Number

Recently a team at the University of Central Missouri, headed by Curtis Cooper has announced, via press release from the Mersenne organization

to have discovered a new largest prime. The number  have more than 22M digits,  to be precise. It's so large that writing 4 digits per centimeter one would be able to cover the entire distance between Edinburgh and Glasgow! Here the full http://www.filedropper.com/largestprimenumber number.

The following is an Haskell micro-script for computing and writing the number to a file (using Haskell because it's lazy input/output allows to write big files to disk without any concern about memory).


import Data.Time
import System.Environment (getArgs)
main :: IO ()
main = do
[path]<-getArgs
let n = 2^74207281 -1
startTime <- getCurrentTime
writeFile path (show n)
stopTime <-getCurrentTime
putStrLn ("ElapsedTime: " ++ show (diffUTCTime stopTime startTime))



Compile using using : ghc --make

and execute passing the output filename as the only parameter.

The full number is ~22MB, not surprisingly as one char occupies one byte in memory.

Here the first digits of the number:

###### 300376418084606182052986098359166050056875863030301484843941693345547723219067 994296893655300772688320448214882399426727835290700904836432218015348199652241 372287684310213386284573666361506667532122772859359864057780256875647795865832 142051171109635844262936572650387240710147982631320437143129112198392188761288 503958771920355017186438665809954286344460536606761717933683749624756782578361 731044883934155387085250868537297205931251606849781532670414744928294883449429 443999003776831072496868250622866039978884541062234219154504645252386846303469 724807334155852889497374778705327594144808269546049745682886662634337786061551 354498294392788969717277814170247857840825173814169979529718831378258156460855 598404801012277963664118162318740241984446339571147500893873350471752282309276 960908368218257475857949333688648781647084935600389442816615101269892941620923 700583920438303155576675128697727353015966198570119971508975499769430113632520 704976596018662818527213338297501690033894692212329648575780270141964029454297 379598752963111110166054910922708870780155972725875622704085120422206985800208 953699779570148521239387340972873010415557408840313517334104245951181312377569 862268931591236073913864912702341514442871893227806578339072908082737776944438 541558625494782239705021522924186805591226430219483495972094802701924328600534 393128646703341368026587734561209964921713257134223641483136379023890310042525 635413014854847842999675719601547926712259803033804208054192341842074795499467 736417866657681142429045674308204219551025449960330608429729874249539051023991 353492744406378092116867003111452756638147874006136238963152211561563090034814 454337404268972669143336589608026262105540337915734652847488347593274189154190 268344381703937005859988258738844104703265786972872467031538046586054465054455 ....

Be the first to leave a comment. Don’t be shy.