&otheprimes,thefirsttwentyofthemare:
2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71。
eartheverybeginningofthenumbersequence,primesareohereislittleopportunityforsmallohavefactorizatioheprimesbeerarer。Forexample,thereisoripleofsees:thetrio3,5,7isunique,aseverythirdoddnumberisamultipleof3,andsothiseverhappenagaihinningproeoceis,however,quiteleisurelyandsurprisiiple,thethirtieshaveonlytwoprimes,thosebeing31aimmediatelyafter100therearetwo‘secutive’pairsoftwinprimesin101,103and107,109。
Theprimeshavebeenasourceoffasforthousandsofyearsbecausethey(aclaimthatweshalljustifyier)yettheyariseamouralnumbersihaphazardfashion。ThismysteriousaablefacetoftheirnatureisexploitediographytosafeguardtialunitheI,whichisthesubjectofChapter4。
gforprimality:primedivisibilitytests
&simple-mindedwayoffindingalltheprimesuptoagivennumbersuchas100istowriteallthenumbersdownandcrossoffthebersasyoufiahodbasedonthisideaiscalledtheSieveofEratosthenesandrunsasfollows。Beginbyg2andthencrossoffallthemultiplesof2(theotherevennumbers)inyourlist。Thehebeginninumberyoumeetthathasnotbeencrossedoff(whichwillbe3)andthencrossoffallitsmultiplesintheremaininglist。Byrepeatingthisprocesssuffitlyoften,theprimeswillemergeasthosecrossedout,althoughsomewillbedsomenot。Forexample,Figure1showsthewsofthesieveupto60。
Howdoyouknowwhenyoustopsieviorepeatthisprotilyouumberthatisgreaterthanthesquarerootestnumberinyourlist。Forinstance,ifyoudoyourownsieveforallo120,youwillhthesieveformultiplesof2,3,5,and7,andwhenyoucircle11youstop,as112=121。Atthatpoint,youwillhavecircledasfarasthefirstprimeexgthesquareroestnumber(120inthiscase)withtheremaiiouched。Allberswillnowhavebeeaseachisamultipleofoneormoreof2,3,5,and7。
1。Primesieve:theprimesupto60arethecrossedout
Itisveryeasytotestfordivisibilityby2andby5astheseprimesaretheprimefaberbasetehis,youoochealdigitofthenumberion:nisdivisibleby2exaitsunitsdigitiseven(i。e。0,2,4,6,or8),andnhas5asafadonlyifitendsin0or5。Nomatterhowmanydigitsthenumbernhas,weoocheckthelastdigittodetermiherleof2orof5。Forprimesthatdoo10,weodoabitmoreworkbutherearesimpletestsfordivisibilitythataremuchquirestodoingthefulldivisionsum。
Anumberisdivisibleby3ifandonlyifthesameistrueofthesumofitsdigits。Forexample,thesumofthedigitsofn=145,373,270,099,876,790is87and87=3×29andsonisinthiscasedivisibleby3。Ofcourse,lythetesttotheselfaakingthesumofdigitsoftheouteateachstageuisobvious。Doingthisfivenexampleproducesthefollowingsequence:
145,373,270,099,876,790→87→15→6=2×3。
Youwillseethatallthedivisioedherearesoquickthatyoudlehdozensofdigitswithrelativeeaseeventhoughthesenumbersarebillioerthahwhichyourhandcalculatorcope。
&sgiveheremaio20arebecausetheyareallofthesamegeheseroutinesareallsimpletoapply,althoughitislessobviouswhytheywhthejustifisarenotrecordedhere,theproofsoftheirvalidityarenotespeciallydifficult。
n=27,916,924→2,791,684→279,160→27,916→2,779→259→7
andsonisdivisibleby7。Eachtimewerunthroughtheloopofinstrus,weloseatleasto,sothenumberofpassesthroughtheloopisaboutthesameasthelengthofthehwhichwebegin。
&herornotnhasafactorof11,subtraaldigitfrtrunumbera。Forexample,thenumberisamultipleof11asourmethodreveals:
4,959,746→495,968→49,588→4,950→495→44=4×11。
Tocheckfordivisibilityby13,addfourtimesthefinaldigitttrunumberah7and11。Foriheurnsouttohave13asosprimefactors:
11,264,331→1,126,437→112,671→11,271
→1131→117→39=3×13。For17andfor19,wesubtractfivetimesthefinaldigitinthecaseof17,andaddtwialdigitwheingif19isafaoreapplyingthissteptothetrunumberthatremaiheprocessasoftenasweneed。Forexample,wetest18,905fordivisibilityby17:
18,905→1,865→161→11
soitisnotamultipleof17,butfor19,thetestgivestheopposite:
18,905→1,900=100×19。
&hisbatteryoftests,youreadilychecktheprimalityofallo500(as232=529exceeds500,so19isthelargestpotentialprimefactorthatyouneedyourselfwith)。Forexample,tosettlethematterfor247,wejustocheckfordivisibilityuptotheprime13(asthesquareoftheprime,172=289,exceeds247)。Applyifor13,however,welearnfrom247→(24+28)=52→13,thatleof13:(247=19×13)。
Thedivisibilitytestsforprimesountediofurnishdivisibilitytestsforthosearesquare-freeproductsoftheseprimes(divisiblebythesquareofanyprime)suchas42=2×3×7:anumbernwillbedivisibleby42exarioofdivisibilitytestsfor2,3,asforthosehavesquarefactors,suchas9=32,doically,althoughitisthecasethatnhas9asafadonlyifthatistrueofthesumofthedigitsofn。
Youmightask,afterthousandsofyears,haven’tthoseclevermathematieupwithbetteraicatedmethodsoftestingforprimality?Theanswerisyes。In2002,arelativelyquickwaywasdiscoveredtotestifagivennumberisprime。Theso-called‘AKSprimalitytest’doesnot,however,providethefactorizationofthegivehappee。Theproblemoffindingtheprimefactivehoughinprinciplesolvablebytrial,stillseemspractitraelylargeintegers,andforthatreasonitformsthebasisofmuaryeno,asubjecttoillreturninChapter4。Beforethatweshall,iters,lookalittlemorecloselyatprimesandfactorization。