> stirling := proc(n) evalf(sqrt(2*n*Pi)*(n/E)^n); end; stirling := proc(n) evalf(sqrt(2*n*Pi)*(n/E)^n) end -------------------------------------------------------------------------------- > for n from 10 to 100 do print(n!, stirling(n)); od; 7 3628800, .3598695626*10 8 39916800, .3961562512*10 9 479001600, .4756874876*10 10 6227020800, .6187239490*10 11 87178291200, .8666100197*10 13 1307674368000, .1300430726*10 14 20922789888000, .2081411446*10 15 355687428096000, .3539483298*10 16 6402373705728000, .6372804647*10 18 121645100408832000, .1211127870*10 19 2432902008176640000, .2422786855*10 20 51090942171709440000, .5088861750*10 22 1124000727777607680000, .1119751498*10 23 25852016738884976640000, .2575852547*10 24 620448401733239439360000, .6182979299*10 26 15511210043330985984000000, .1545959490*10 27 403291461126605635584000000, .4020009947*10 29 10888869450418352160768000000, .1085531522*10 30 304888344611713860501504000000, .3039823279*10 31 8841761993739701954543616000000, .8816392149*10 33 265252859812191058636308480000000, .2645170972*10 34 8222838654177922817725562880000000, .8200764742*10 36 263130836933693530167218012160000000, .2624465156*10 37 8683317618811886495518194401280000000, .8661418433*10 39 295232799039604140847618609643520000000, .2945100979*10 41 10333147966386144929666651337523200000000, .1030857522*10 42 371993326789901217467999448150835200000000, .3711332512*10 44 13763753091226345046315979581580902400000000, .1373278938*10 45 523022617466601111760007224100074291200000000, .5218769246*10 47 20397882081197443358640281739902897356800000000, .2035434450*10 48 815915283247897734345611269596115894272000000000, .8142172702*10 50 33452526613163807108170062053440751665152000000000, .3338460432*10 52 1405006117752879898543142606244511569936384000000000, .1402221234*10 53 60415263063373835637355132068513997507264512000000000, .6029829514*10 55 2658271574788448768043625811014615890319638528000000000, .2653241840*10 57 119622220865480194561963161495657715064383733760000000000, .1194009078*10 58 5502622159812088949850305428800254892961651752960000000000, .5492662865*10 60 258623241511168180642964355153611979969197632389120000000000, .2581651048*10 62 12413915592536072670862289047373375038521486354677760000000000, .1239238277*10 608281864034267560872252163321295376887552831379210240000000000, 63 .6072482694*10 30414093201713378043612608166064768844377641568960512000000000000, 65 .3036344619*10 1551118753287382280224243016469303211063259720016986112000000000000, 67 .1548586361*10 80658175170943878571660636856403766975289505440883277824000000000000, 68 .8052902110*10 4274883284060025564298013753389399649690343788366813724672000000000000, 70 .4268167169*10 230843697339241380472092742683027581083278564571807941132288000000000000, 72 .2304877382*10 12696403353658275925965100847566516959580321051449436762275840000000000000, 74 .1267718128*10 710998587804863451854045647463724949736497978881168458687447040000000000000, 75 .7099413593*10 40526919504877216755680601905432322134980384796226602145184481280000000000000, 77 .4046771391*10 2350561331282878571829474910515074683828862318181142924420699914240000000000000 , 79 .2347186570*10 1386831185456898357379390197203894063459028767726874325408212949401600000000000\ 00 , 81 .1384873799*10 8320987112741390144276341183223364380754172606361245952449277696409600000000000\ 000 , 82 .8309438401*10 5075802138772247988008568121766252272260045289880360030994059394809856000000000\ 00000 , 84 .5068872834*10 3146997326038793752565312235495076408801228079725823219216316824782110720000000\ 0000000 , 86 .3142770403*10 1982608315404440064116146708361898137544773690227268628106279599612729753600000\ 000000000 , 88 .1979987595*10 1268869321858841641034333893351614808028655161745451921988018943752147042304000\ 00000000000 , 90 .1267218250*10 8247650592082470666723170306785496252186258551345437492922123134388955774976000\ 000000000000 , 91 .8237083629*10 5443449390774430640037292402478427526442930643887988745328601268696710811484160\ 00000000000000 , 93 .5436580801*10 3647111091818868528824985909660546442716763531404952459370162850026796243694387\ 2000000000000000 , 95 .3642577775*10 2480035542436830599600990418569171581047399201355367672371710738018221445712183\ 296000000000000000 , 97 .2476998195*10 1711224524281413113724683388812728390922705448935203693936480409232572797541406\ 47424000000000000000 , 99 .1709159109*10 1197857166996989179607278372168909873645893814254642585755536286462800958278984\ 5319680000000000000000 , 101 .1196432019*10 8504785885678623175211676442399260102885846081207962358864307633885886803780790\ 17697280000000000000000 , 102 .8494809767*10 6123445837688608686152407038527467274077809178469732898382301496397838498722168\ 9274204160000000000000000 , 104 .6116362736*10 4470115461512684340891257138125051110076800700282905015819080092370422104067183\ 317016903680000000000000000 , 106 .4465015589*10 3307885441519386412259530282212537821456832518209349711706119268354112357009715\ 65459250872320000000000000000 , 108 .3304162507*10 2480914081139539809194647711659403366092624388657012283779589451265584267757286\ 7409443815424000000000000000000 , 110 .2478159088*10 1885494701666050254987932260861146558230394535379329335672487982961844043495537\ 923117729972224000000000000000000 , 112 .1883428444*10 1451830920282858696340707840863082849837403792242083588467815746880619913491564\ 20080065207861248000000000000000000 , 114 .1450260553*10 1132428117820629783145752115873204622873174957948825199004896282566883532523420\ 0766245086213177344000000000000000000 , 116 .1131218926*10 8946182130782975286851441715398316520698082167795719072138680632278379906935018\ 60533361810841010176000000000000000000 , 117 .8936750380*10 7156945704626380229481153372318653216558465734236575257710944505822703925548014\ 8842668944867280814080000000000000000000 , 119 .7149494568*10 5797126020747367985879734231578109105412357244731625958745865049716390179693892\ 056256184534249745940480000000000000000000 , 121 .5791165075*10 4753643337012841748421382069894049466438132940679933286171609340767439947348991\ 48613007131808479167119360000000000000000000 , 123 .4748814941*10 3945523969720658651189747118012061057143650340764344627522435752836975156299662\ 9334879591940103770870906880000000000000000000 , 125 .3941564665*10 3314240134565353266999387579130131288000666286242049487118846032383059131291716\ 864129885722968716753156177920000000000000000000 , 127 .3310953892*10 2817104114380550276949479442260611594800566343305742064051019127525600261597959\ 33451040286452340924018275123200000000000000000000 , 129 .2814343654*10 2422709538367273238176552320344125971528487055242938175083876449672016224974245\ 0276789464634901319465571660595200000000000000000000 , 131 .2420363133*10 2107757298379527717213600518699389595229783738061356212322972511214654115727593\ 174080683423236414793504734471782400000000000000000000 , 133 .2105739381*10 1854826422573984391147968456455462843802209689493993466844215809868895621840281\ 99319100141244804501828416633516851200000000000000000000 , 135 .1853070825*10 1650795516090846108121691926245361930983966623649654185491352070783317103437850\ 9739399912570787600662729080382999756800000000000000000000 , 137 .1649250581*10 1485715964481761497309522733620825737885569961284688766942216863704985393094065\ 876545992131370884059645617234469978112000000000000000000000 , 139 .1484340967*10 1352001527678402962551665687594951421475868664769066777917417345971536707715599\ 94765685283954750449427751168336768008192000000000000000000000 , 141 .1350764024*10 1243841405464130725547532432587355307757799171587541435684023958293813771098351\ 9518443046123837041347353107486982656753664000000000000000000000 , 143 .1242715272*10 1156772507081641574759205162306240436214753229576413535186142281213246807121467\ 315215203289516844845303838996289387078090752000000000000000000000 , 145 .1155736459*10 1087366156656743080273652852567866010041868035801828723074973744340451998694179\ 27630229109214583415458560865651202385340530688000000000000000000000 , 147 .1086402628*10 1032997848823905926259970209939472709539774634011737286921225057123429398759470\ 3124871765375385424468563282236864226607350415360000000000000000000000 , 149 .1032092127*10 9916779348709496892095714015418938011581836486512677954443760548384922228090914\ 99987689476037000748982075094738965754305639874560000000000000000000000 , 150 .9908174963*10 9619275968248211985332842594956369871234381391917297615810447731933374561248187\ 5498805879175589072651261284189679678167647067832320000000000000000000000 , 152 .9611015728*10 9426890448883247745626185743057242473809693764078951663494238777294707070023223\ 798882976159207729119823605850588608460429412647567360000000000000000000000 , 154 .9418877979*10 9332621544394415268169923885626670049071596826438162146859296389521759999322991\ 56089414639761565182862536979208272237582511852109168640000000000000000000000 , 156 .9324769292*10 9332621544394415268169923885626670049071596826438162146859296389521759999322991\ 5608941463976156518286253697920827223758251185210916864000000000000000000000000 , 158 .9324847782*10 -------------------------------------------------------------------------------- > ?modulo Try one of the following topics: {modp, modp1, liesymm[mod], grobner[normalf]} -------------------------------------------------------------------------------- > ?modp -------------------------------------------------------------------------------- > ?irem -------------------------------------------------------------------------------- > isprime(199); true -------------------------------------------------------------------------------- > irem(76^199,199); 76 -------------------------------------------------------------------------------- > for i from 0 to 198 do irem(i^199,199); od;\ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 -------------------------------------------------------------------------------- > ?modexp Try one of the following topics: {mod, modp1, mods, mod2, mode, modpol} -------------------------------------------------------------------------------- > ?irem -------------------------------------------------------------------------------- > ?exp -------------------------------------------------------------------------------- > ?power_mod Try one of the following topics: {powseries, Power, Powmod, power, powdiff, powerpc, powerps, powexp, powint, powlog, powpoly, powset, powsubs, powerseries, powcreate, powerset, powsolve, powmod} -------------------------------------------------------------------------------- > for i from 1 to 6 do ifactor(2^(2^i) + 1); od; (5) (17) (257) (65537) (641) (6700417) (67280421310721) (274177) -------------------------------------------------------------------------------- > q := 2^(2^5) + 1; q := 4294967297 > isprime(q); false -------------------------------------------------------------------------------- > irem(587^q, q); Error, integer too large in context -------------------------------------------------------------------------------- > power_mod:=proc(a, e, m)\ # compute a^e mod m \ local half;\ if e = 0 then RETURN(1) fi;\ if e = 1 then RETURN(irem(a, m)) fi;\ half := power_mod(a, iquo(e, 2), m);\ if type(e,even)\ then RETURN(Expand(half*half) mod m)\ else RETURN(Expand(half*half*a) mod m)\ fi\ end;\ power_mod := proc(a,e,m) local half; if e = 0 then RETURN(1) fi; if e = 1 then RETURN(irem(a,m)) fi; half := power_mod(a,iquo(e,2),m); if type(e,even) then RETURN(Expand(half^2) mod m) else RETURN(Expand(half^2*a) mod m) fi end -------------------------------------------------------------------------------- > power_mod(587, q, q); 4024557553 -------------------------------------------------------------------------------- > binomial(199,64); 115508290439911866982041170124506852630663205414409311 -------------------------------------------------------------------------------- > irem(",199); 0 -------------------------------------------------------------------------------- > ifactor(""); 2 (3) (7) (11) (13) (17) (23) (37) (47) (71) (73) (79) (83) (89) (97) (137) (139) (149) (151) (157) (163) (167) (173) (179) (181) (191) (193) (197) (199) -------------------------------------------------------------------------------- >