1 / 123

数的计算及其延伸 (daode1212)

数的计算及其延伸 (daode1212). 浙江省安吉县教研室 项道德. 数的发展. 小学 : 整数  分数  小数 中学 : 有理数  实数  复数 大学 : 向量  矩阵. 计算工具的发展. 中国 : 1, 结绳  卦象  天干 地支  阴阳风水学 2, 结绳  算筹  笔算算盘 国外 : 笔算计算尺  计算器  计算机 ( 电脑 ). 几次大的整合与分流发展. 与几何学整合  解析几何学 极限理论  微积分学 多元化  高等代数 ………… 近代发展新领域 : 1, 概率与统计、张量分析、拓扑学 ;

kaili
Télécharger la présentation

数的计算及其延伸 (daode1212)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 数的计算及其延伸(daode1212) 浙江省安吉县教研室 项道德

  2. 数的发展 • 小学:整数分数小数 • 中学:有理数实数复数 • 大学:向量矩阵

  3. 计算工具的发展 • 中国: • 1,结绳卦象天干\地支阴阳风水学 • 2,结绳算筹笔算算盘 • 国外: • 笔算计算尺计算器计算机(电脑)

  4. 几次大的整合与分流发展 • 与几何学整合解析几何学 • 极限理论微积分学 • 多元化高等代数 • ………… • 近代发展新领域: • 1,概率与统计、张量分析、拓扑学; • 2,组合数学与算法;

  5. 人脑|电脑发展各有方向 • 人脑训练方向: • 提出问题,提出策略(算法),提出质疑. • 电脑发展方向: • 高速度,大容量,智能化,工具化

  6. 今天展示以下领域核心技术 一、任意大整数的计算: 大整数相乘,高次幂,阶乘, 整除性、质数与合数,GCD,LCM 同余与同余式、进制转换。 二、任意位小数的计算: 除法,开方,函数计算,表达式计算。

  7. 一,若干数学笔算题目

  8. 二,若干数学探究题目

  9. 密码问题之一 • X88黑客生于88年,被捕后交待:她个人帐户的密码是88!的前16位,她的银行账号为8888的前16位,求出他的两个密码!

  10. 密码问题之二 • KGB导弹系统由三人把守,每人的密码都是6位的质数,而且当且仅当这三个质数的积是662604783861269791时,导弹可以引发。求这三个质数密码。

  11. 密码问题之三 • W3组织处理命令加密时用如下法则: A年B月C日发的命令用An+Bn +Cn作为密钥加密后发送(n为工号) ,计算今天向33号成员发送命令所用的密钥。

  12. 天文测量之一 • 激光测距,光速:299792458米/秒,在65536秒正好收到反射光1次,求激光头到被测物体之间的距离?

  13. 天文测量之二 • 天文预测常用最小公倍数计算诸如月食与日食之类的现象。设M星绕太阳一周需68686868秒,N星绕太阳一周需84848484秒,求这两星球两次相遇间隔时间多少秒?

  14. 三,解决思路 一、用笔算; 二、计算器; 三、电脑: 1、设计算法编程计算; 2、用已有软件计算; 3、用已有库函数计算;

  15. PHP-BC库函数运用引领 • bcadd---Add two arbitrary precision numbers • bccomp---Compare two arbitrary precision numbers • bcdiv---Divide two arbitrary precision numbers • bcmod--- Get modulus of an arbitrary precision number • bcmul---Multiply two arbitrary precision number • bcpow--- Raise an arbitrary precision number to another • bcpowmod--- Raise an arbitrary precision number to another, reduced by a specified modulus • bcscale--- Set default scale parameter for all bc math functions • bcsqrt--- Get the square root of an arbitrary precision number • bcsub--- Subtract one arbitrary precision number from another

  16. GMP Functions • These functions allow you to work with arbitrary-length integers using the GNU MP library ……………… gmp_perfect_square---Perfect square check gmp_popcount---Population count gmp_pow---Raise number into power gmp_powm---Raise number into power with modulo gmp_prob_prime---Check if number is "probably prime" gmp_random---Random number ………………

  17. 运算库[GMP]来自: http://www.swox.com/gmp/ 所有运行由 GNU MP库支持. 版本应高于 PHP 4.0.4. 本次演示所用版本:PHP 5.2.3.3 通常架设WEB服务器运行. 在客户端运算需要DAODE-X的专门程序. runPHPfileHTM.exe

  18. BC库的主要功能 • 提供任意精度的下列计算: • 加、减、乘、除; • 乘方; • 平方根; • 除法取模、乘方取模; • 两数大小比较; • ………………

  19. GMP库的主要功能 • 提供任意精度的下列计算: • 加、减、乘、除; • 乘方; • 平方根; • 除法取模、乘方取模; • 阶乘、最大公约数; • 质数判断; • 二进制运算; • ……… • 目录 • gmp_abs -- Absolute value • gmp_add -- Add numbers • gmp_and -- Logical AND • gmp_clrbit -- Clear bit • gmp_cmp -- Compare numbers • gmp_com -- Calculates one's complement • gmp_div_q -- Divide numbers • gmp_div_qr -- Divide numbers and get quotient and remainder • gmp_div_r -- Remainder of the division of numbers • gmp_div -- 别名 gmp_div_q() • gmp_divexact -- Exact division of numbers • gmp_fact -- Factorial • gmp_gcd -- Calculate GCD • gmp_gcdext -- Calculate GCD and multipliers • gmp_hamdist -- Hamming distance • gmp_init -- Create GMP number • gmp_intval -- Convert GMP number to integer • gmp_invert -- Inverse by modulo • gmp_jacobi -- Jacobi symbol • gmp_legendre -- Legendre symbol • gmp_mod -- Modulo operation • gmp_mul -- Multiply numbers • gmp_neg -- Negate number • gmp_or -- Logical OR • gmp_perfect_square -- Perfect square check • gmp_popcount -- Population count • gmp_pow -- Raise number into power • gmp_powm -- Raise number into power with modulo • gmp_prob_prime -- Check if number is "probably prime" • gmp_random -- Random number • gmp_scan0 -- Scan for 0 • gmp_scan1 -- Scan for 1 • gmp_setbit -- Set bit • gmp_sign -- Sign of number • gmp_sqrt -- Calculate square root • gmp_sqrtrem --  Square root with remainder • gmp_strval -- Convert GMP number to string • gmp_sub -- Subtract numbers • gmp_xor -- Logical xOR

  20. MATH函数集 is_finite -- 判断是否为有限值 is_infinite -- 判断是否为无限值 is_nan -- 判断是否为合法数值 lcg_value -- 组合线性同余发生器 log10 -- 以 10 为底的对数 log1p --  返回 log(1 + number),甚至当 number 的值接近零也能计算出准确结果 log -- 自然对数 max -- 找出最大值 min -- 找出最小值 mt_getrandmax -- 显示随机数的最大可能值 mt_rand -- 生成更好的随机数 mt_srand -- 播下一个更好的随机数发生器种子 octdec -- 八进制转换为十进制 pi -- 得到圆周率值 pow -- 指数表达式 rad2deg --  将弧度数转换为相应的角度数 rand -- 产生一个随机整数 round -- 对浮点数进行四舍五入 sin -- 正弦 sinh -- 双曲正弦 sqrt -- 平方根 srand -- 播下随机数发生器种子 tan -- 正切 tanh -- 双曲正切 abs -- 绝对值 acos -- 反余弦 acosh -- 反双曲余弦 asin -- 反正弦 asinh -- 反双曲正弦 atan2 -- 两个参数的反正切 atan -- 反正切 atanh -- 反双曲正切 base_convert -- 在任意进制之间转换数字 bindec -- 二进制转换为十进制 ceil -- 进一法取整 cos -- 余弦 cosh -- 双曲余弦 decbin -- 十进制转换为二进制 dechex -- 十进制转换为十六进制 decoct -- 十进制转换为八进制 deg2rad --  将角度转换为弧度 exp -- 计算 e(自然对数的底)的指数 expm1 --  返回 exp(number) - 1,甚至当 number 的值接近零也能计算出准确结果 floor -- 舍去法取整 fmod -- 返回除法的浮点数余数 getrandmax -- 显示随机数最大的可能值 hexdec -- 十六进制转换为十进制 hypot --  计算一直角三角形的斜边长度

  21. 三,阶乘计算 5!=5x4x3x2x1=120

  22. 练一练:我们都是数学老师 • 2!+ 3!=? • 5!- 2!=? • 2!× 3!=? • 5!÷ 2!=? • 6!=? • 求 3600与 4800的最大公约数与最小公倍数。 • 求 6!与 5!两数的最大公约数与最小公倍数。 • 求3600的约数个数、全部约数的和。 • 求6!的约数个数、全部约数的和。

  23. 100!相关题目 设基因工程要对100个基因片断进行全排列: 100!末尾连续的“0”有多少个? 100!头16位是什么? 100!中会出现“9999”吗? 100!质因数“幂-积”形式展开? 100!有多少个约数? 100!全部约数的和?

  24. 100!=? • 100! =93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000

  25. 100!因数与质因数分析 各质因数:2^97×3^48×5^24×7^16×11^9×13^7×17^5×19^5×23^4×29^3×31^3×37^2×41^2×43^2×47^2×53^1×59^1×61^1×67^1×71^1×73^1×79^1×83^1×89^1×97^1 因数统计[计算式]:(97+1)(48+1)(24+1)(16+1)(9+1)(7+1)(5+1)(5+1)(4+1)(3+1)(3+1)(2+1)(2+1)(2+1)(2+1)(1+1)(1+1)(1+1)(1+1)(1+1)(1+1)(1+1)(1+1)(1+1)(1+1) 因数个数[计算值]:39001250856960000

  26. N!头K位数有规律(n=1000,k=3周围)

  27. N!末K位数有规律??? • (n=1000,k=4附近)

  28. 用乘法进行阶乘计算1000!=? • <?phpfunction fact($x) {$return = 1;for ($i=2; $i < $x; $i++) {$return = gmp_mul($return, $i);}return $return;}echo gmp_strval(fact(1000)) . "\n";?>

  29. 1000!的计算值,位数:2565 • 402387260077093773543702433923003985719374864210714632543799910429938512398629020592044208486969404800479988610197196058631666872994808558901323829669944590997424504087073759918823627727188732519779505950995276120874975462497043601418278094646496291056393887437886487337119181045825783647849977012476632889835955735432513185323958463075557409114262417474349347553428646576611667797396668820291207379143853719588249808126867838374559731746136085379534524221586593201928090878297308431392844403281231558611036976801357304216168747609675871348312025478589320767169132448426236131412508780208000261683151027341827977704784635868170164365024153691398281264810213092761244896359928705114964975419909342221566832572080821333186116811553615836546984046708975602900950537616475847728421889679646244945160765353408198901385442487984959953319101723355556602139450399736280750137837615307127761926849034352625200015888535147331611702103968175921510907788019393178114194545257223865541461062892187960223838971476088506276862967146674697562911234082439208160153780889893964518263243671616762179168909779911903754031274622289988005195444414282012187361745992642956581746628302955570299024324153181617210465832036786906117260158783520751516284225540265170483304226143974286933061690897968482590125458327168226458066526769958652682272807075781391858178889652208164348344825993266043367660176999612831860788386150279465955131156552036093988180612138558600301435694527224206344631797460594682573103790084024432438465657245014402821885252470935190620929023136493273497565513958720559654228749774011413346962715422845862377387538230483865688976461927383814900140767310446640259899490222221765904339901886018566526485061799702356193897017860040811889729918311021171229845901641921068884387121855646124960798722908519296819372388642614839657382291123125024186649353143970137428531926649875337218940694281434118520158014123344828015051399694290153483077644569099073152433278288269864602789864321139083506217095002597389863554277196742822248757586765752344220207573630569498825087968928162753848863396909959826280956121450994871701244516461260379029309120889086942028510640182154399457156805941872748998094254742173582401063677404595741785160829230135358081840096996372524230560855903700624271243416909004153690105933983835777939410970027753472000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

  30. 5000!= • 422857792660554352220106420023358440539078667462664674884978240218135805270810820069089904787170638753708474665730068544587848606668381273633721089377278763127939036305846216064390447898698223987192970889621161265296832177550039924219683703146907264472878789790404754884162215226671928410969236910449565971736352948400223840381120644820230857671104502306174894755428309761781724040805324809927809328784055486199364548291211876258248802189173977900050213212598043639244626460770511358846595108675470585833924655225589035474435988347383178988034633008458631510209091509935653820010933047965742556741930917055172805200236075085991197635228755907902043369743123506916831211924495971556267407521462198986233088625998302859864857578749445963115286970886710046268423648178989905454690861391613218344174148807186234448114831209490361196546872767755617886828720269104814092456410341835975604276458161513178575901661071782544156980883359372729995603371371200471049437656291142488605335299499642300699972204918120100819059439140675053265004775533850899097945101551091486907004407119572336026243368132330218709287699196806656569752790422258267841561083376425781032629202687211070274681394351128601502326190649959171897364176378436491219709109840944514895358959103804176941956657834822071749105512752639148381172052604826965162642710094919393332661030104360530459117014557209584714353721948246686793467375904872268133410207860903657108806376616249749507413107077401682180585945526445171409277469230062697511346044174567946735828782261629584248675157379172942724178783105429858245117575511884506574424827574660800238588378492396247368761507015767725898321128632295537044902516387925127590841791744640466913531047347984464996154595542013996317357476301740036796192919942190762895445656261767041799538161133387312823511534152581309087915883638351664797225912944270653557142511737323807232632958121797916679692329687096923901003255574789055099807487061047230646195984955239657612208673866514171699307557691897902675157342075864796345338446835085965490727326321910504064289713096224505162064669468098869917122127404504020684923266241760132910227866687270305284709452526825496617772499645206699836925910690894082637401043498371591126455822280606361394115344316771769934353664284928294436414769615881993661388255577487709937004594753907845149034434521174560594039916268444697661821387470705325559577933196460996662145377564935474169708562389214773222865507182490430016186142192760452307670621142961767274704123616107220009743758647492753665149532164780849075146330071016691313420662882562618283865836983632108760710427516073348347788414796732427080410860761841281888307115098982135338406610652147087046874760995427473673509451553599769040367353385551052571682650317682405743993414862392331981432579182193321898940450865013610998098383993110996355981328001049731588596312131853801205046787642910669365600437305633431984879048998524701293300789344532868156679762880495532846386020133480265279836946393384995675049993707814746561543438930431384237878981847802886009971088695632988347711863122382785963653115132377931373647397429369411499028751972227999545182615488298951151926682112451355318472209990435355949887299922035062039816011086376236539782172380237846650673624510635034423187315338308212043804710999419227821039747552717416043890169723961305549371844836119803565896062025009093664399360172007383613354405094329072476518909502507724675841989412224659392163116352038147362479528539732089309533421910635702805576629720156556510767780805933453631121829561792887673002802450932122778852968418208261778476955644980385691275787372678040959158711733971103165232678060798127609246173504120182666874262805385275843979167609007743380748420751185119102921960339376280986753665085212869255321536787932521882574101866137054328973735862725370178558806639851350386944039604928258820180419178073649693885802597758398892014389747165465973510852605706234402069637065660129535734043582961473427275805630839510667375349259659518575646939723218275780003250593895303820539697558870511543073920827422440516299708739599768461206246629098112368012579891284802505094028916959765079395437191311379314427405135599630375642214527294341797246187597964074239147838993541565834716156858499036773056611353833367087548900413091981676330749041510337597307246885839246941715548295730750618505881581959528992660225626903439573313450666972952115230668696227920947779974336574472673471408928071411283888082693377378077293104110767513639476200610858040596019639058015761002337463869352228385801434957178125581445862930042479404065736859862007914604590255413929950088044710384758990326548097338166940500085452723713571394902463820308668541802838317527668064278489561005755859991718966786449154063570014497194249878920859731254275567514575206399118150736397483102490793841725653421894276769116598153430084637087769510295415136551734675054015239706042571746001089968440498845985477977905031632568489156557231006499726498721480800181770357701502983008879487243887718884416833034708723239505377642232944095773219137582371673924704216723002256883135779230394688900662466182532658490724406767024939579697217467485562998183149665611743997680482094166257463879660305171274925119226367615337524381656217330771650129520988754856467131862602387619964334867961514408328902061082833180891221325853682856469916007952105166960451695430614212305743006877217407155473217957577017595967640563812729153867513698712395570542350999228605975469962186195531354132139126436676900465429996811680550737866770665988027062972502001882845886145344368771455361304414465613369092862748276981946836480550952968681758714859972973082332924094777085275279923304892719633314751563311192746150389219290616780607901383451137066300684376267199885515143681266137319912103235469786756421210624899005553564022924345831264231038363416781719908354140411717740185950606674198348143345444247191436828225654380047860390575922417071802670646875454211626958746795398540784464654140381751149965273621123540880166990280149033225139460832668170930713868826549977374286127789417784752681328371818759103642140881783220739808059714203285309721443041845459183002833408705783138284973283761286182927136745161897366207237396132790944984014154408304074405393067540767126182547597130843470311389815695365971788564022750674237400323621850094765267521941901241387478279883426470873616812485384444012772521050072279315853096279121131160167772077952572613800240684421885453537121341902236379684012385255288607189967725694227433323948595075570839061877450159652184414998155476107548008054192318436948191732631430603548399790783307267636729090980772827355854348032260067472537097785464567761181807367424367391769863758072145859791485033700592994963793369100283444558089838054017635403737133019311293080958287612107380374800660269767842888358265737486556785868822015143046249655995760379768685318192365806469199584071845493606922169776137542662239658644989770921478134709127917460871630220821981434654245065731262683089579031012893360788644107230184805400373136014216229159146992019884148290014414312800903102107833305090238435726779416177246873411503598700003151092815700331081727415624680432977205070450456683898626301702989301145364477416856732512330376477881749036052572605520684370616116539755132541369303867783267208227323664249206432363089268768826650939691861683271739757479552993242406186992420363781929485368098035256331092448215269276219116259145886393677034653480367887126133367116968226450914997055448521259751870084720025674658752403932061045903070039438252019383102480929019684602472171298321628237994627125366359971898374425099120673688383738299653892030662843074547559074235345274029211606091346327684749522046010409575607348155101677203187580089224494752922031093841661588823584993931745149914395557357641584185479831702428523965451087525425464777294595230360946416541997797947136806344915998772409176443137371178542210740572121166868692153240490080384205921192622875440898261478908123698956367080804687628524499897440855677969456909042340530355943524640751677873953113928698614347227572144946891896093294375476741234907792754338349412323060078767610089949156126934038921148370217193387617823370358925817112869563450001367619897145400986643461922197676975930010555225198913002123021780831934330880446592954552165911855939202579781122952065357362914478404946474565003115498072056580360667380889572746464375428055819322299305089287806874537401327100274428317925355003451536693172112088227603942809788645727306979971285649576934354004030728440581746648376658498039958964243370183454151720285337810904113124462432903353964296651109482836884580127588701293156099225044518125460113274986014470437757313881001319276124676116614833528935557503106018449788994378274613854651708241613167681463911870000812845144341406739985430072772303758111613511094355614896323929750846383152930263582535361784837558519666949972251935515953807207838615142130284450051795239760968433198292598921623223582396390262548856855875458198371559008447860086745945709118128793228222051767509371866110013193625845223493949829511199280837860523506412769337548130609594264463425077601147334209139128541628183172262143783062962408149391997187528106367348876678481602342743230027158192404187686545826519361990687336892886715133840245486110982482004482721799496658712257174429044916781194824165631560303473833317665121218052780795958220298330611945164019413315550379662980215357680731124530585915969709973988055743550083279071844959752353594644354789680372126344509423070253995102864458237454677761013556916212309752286152053213998745673034127676503369636682306665552051562491132528926155863868503100849180920507680658265915276163719928694258350604859732273949286080260640627521341007801815105623787926212039424781833439433877206395801115809084190794320195178235740190546595990289617711776195270354051193727229722248442080440098750369411277686593022133010625031862085145076421052980508837197986052557750303949606158442838846866137510968441567309838079394349570013029265177957120625555851951313574029897589283475525334409858911400694449308432874005015554332587793895080241128538758725945136400838324944471346436826148195406004114845870234072926697740631325878634790667698266181501256117692275715291249164821702372884416357600996851100939411444677628186007072278522314941048564396255796808221289935799262208553889221164765220850367706476491496133789353761537391569177822237744837614120253342622508007300513473422771427333106345971803240244226950458090539326689103619381998838844036231795282435495362489670734155948067688515321073064476077859628627852283657244564306449096277517172656954238392941958409527253281659572534531428389629894005886539486824117113929627356938973482935854650278689437014798383826002058208853517073216288725214522205265969614962147884840129004507737252424605074339660818182960296019196314124998538422017695110361380561701016357743542531148669369994130940908368220071936435111978592782493491477052187226546109199597269439152400467901173602521030051886080337084840114810246351288263986170081804888380750203521448348740849154718714478857809574515499505005070789428842888410027877777455981132319940624176532148686316581736774410084063436959989519288310869124517866342559353458242589411390516469440377562665821577845936829909679754548350510473633770839151033854639602753486401635204633884342346714935641429160856846724874244782055113759168236472297793612971080302530934478115527737540458968990354808058309381267323593563098546564376209385371052808344607189076003388781618019853273759498566916704703448438363503416368325266403224174519476678140428319327482851882140344319384445475456765253419659194332132585432270070759038565239668227171300009189122050845185261514627937717597528852978637931711212529529443323757910072909001703558763798612480281463093944391916950129336315045285163539312868586427437296109446101235604877439863299611899755965996608749049271167685268675335991297583209089553296409523640116060078495005377892783750147344122123777907727134146647404489837589487675423294546899354220341669961366698976529978580795899055864050388507083137333076839766882463680992355219727241831735127646189112380485883115569477888101759708977682149644340317924443085170303692214137621194388641989508360339306459037361842937028710758321966607546113761076362543928614316242890754021082233620012309384737312220374269033838579928678572939434168287053763374091938184632261131740934278117918891642447513543478446040549455379834556163353815868441692054518698919434175386663900335756765603264363767906721626620330878425545157208117246381251512669846685887209013144861632560461019513371814585249988176629925142145014710206193190373671380347663431029705222414785030188275106347446241258707937339085095757724316735066885094208761536164440443755860160625837091300574162065273670941888667964570550744724714137001968165215954380698515999483361357521322106131884771926641942395351412233546746461491743013475866037338176532604557402925472279360288926189385899695656876783017186873988763887625972743976062813263446647679413679726184933395074665820441677989806604203937116666336696282569349097348391155869004856032512219241534268522369316036765491047702733521540143168338872968405443296967684036073182435336224865433823598123544167514608340781166661858781733980624199254577853462678039039937557802759942957205281043775666979396838109341118959475766220191217535093638985465283078692370662512323684390235587636228324657161183714078807661162179517887972801841572019639084400269037450381192797170314489871815031319992111563908303017288012610642062005359240278277393918026391717720136125984776933980647063763022608885359937595079088789081791802195768033381968605120487107610874898411568740159953020639098138993261095538868264084012160831040525974539251576403732889086736948366404734622708560040891610782221943405179794550155347682966855320097501905581419914591124181501062255627411231571377358697194374130822027383843815940638571387913337592362330440453487233047240668784133333047898995255221468847973813568083995644533005222551320155267768895412770329278670827490041172076663112783638152343547681663121189086864991380236281775275946061211813342054791801619220346912760381900528012343973598270461499814511324618195658528232044658270082064934680251556511272822083811563192256509945201222666603226059396247019707668580396286975551115189973049085051758765306785758000660424066894170620303846785860257370634352599586885088679654004465187790208942935153217316750113738031466034642429489076322228133763299919641336502028627289268087560036613770607463575515079087982099722660130472907825746908175451952405573791313113170617323191598673971588373108168916968657704150695512947652386134815766967580364762005289060222744531744305498402863048850869557761528650326080941160688570698894762046478500884303973107412774191961697450517110329082815201273888663422631492147090220016940636504812047036016738602290671629816411198202268607961324739550057567564568204754619040423011062371367395995678940884705976859514505017241517746017351430990972615509378334720000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

  31. 阶乘专用函数---GMP_fact() • <?php • dl('php_gmp.dll'); • $fact2 = gmp_fact(5000); • echo gmp_strval($fact2) . "<br>"; • echo strlen(gmp_strval($fact2)) . "---len<br>"; • ?> 5000! =? Len=16326

  32. 5000!的分析研究 ‘ 分类 数目 位数 百分比 '末尾连0 1249 16326 7.6504% '0的个数 1533 16326 9.3899% '1的个数 1536 16326 9.4083% '2的个数 1463 16326 8.9612% '3的个数 1538 16326 9.4206% '4的个数 1482 16326 9.0775% '5的个数 1468 16326 8.9918% '6的个数 1531 16326 9.3777% '7的个数 1522 16326 9.3226% '8的个数 1522 16326 9.3226% '9的个数 1482 16326 9.0775%

  33. 奇数连乘的运算 <?php dl('php_gmp.dll'); $m=1; for($i=1;$i<1000;$i+=2){ $m = gmp_mul($m, $i); } echo gmp_strval($m); ?>

  34. 999!!的答案: • 100748329763750854004038917392303538250323418583550415705013777513334847930864905026212149922688916514224446856302103818809813965739969905602683824057028542369814437703275217182106137628427025253936696857063927677887236450311036887007989218384076420973974651860279864376153012567675767840733574225799002463604490891982796305162134708837541147007332276627034016790073315219533088052639255340728943149219519187498959529434982654113006616219355830114439411562650611374970334868978510289340267833632215930432706056111069583472778227977585526504938921664232801595705593340414168289146933191250605578218896799783237156997993612173843567447982392426109444012350386990916069363415575527636429080027392875413821124412782341957015410685185402984322002697631153866494712956244870206835064084512590679022924697003630949759950902438767963278695296882620493296103779237046934780464541286585179975172680371269700518965123152181467825566303777704391998857792627009043170482928030252033752456172692668989206857862233381387134495504231267039972111966329704875185659372569246229419619030694680808504265784672316785572965414328005856656944666840982779185954031239345256896720409853053597049715408663604581472840976596002762935980048845023622727663267632821809277089697420848324327380396425724029541015625

  35. 偶数连乘的运算 2x4x6x8x……x200 =2200/2x100! =2100x100! 即: 2x4x6x8x……x(2N) =2NxN!

  36. 阶乘的估算[Stirling’s Series]

  37. 精算与估算的对比 12! by daodefact:47900159812! by gmp_fact:47900160013! by daodefact:622702078713! by gmp_fact:622702080014! by daodefact:8717829107314! by gmp_fact:8717829120015! by daodefact:1.30767436665E+01215! by gmp_fact:1.307674368E+01216! by daodefact:2.09227898724E+01316! by gmp_fact:2.0922789888E+01317! by daodefact:3.556874279E+01417! by gmp_fact:3.55687428096E+01418! by daodefact:6.40237370308E+01518! by gmp_fact:6.40237370573E+01519! by daodefact:1.2164510037E+01719! by gmp_fact:1.21645100409E+017

  38. 一亿的阶乘[100000000!=?]:长度 :7.5657亿位 10! len 估算---:7 100! len 估算---:158 1000! len 估算---:2568 10000! len 估算---:35659 100000! len 估算---:456573 1000000! len 估算---:5565709 10000000! len 估算---:65657059 100000000! len 估算---:756570556 • 10! len 估算---:7 10! len 精算---:7 100! len 估算---:158 100! len 精算---:158 1000! len 估算---:2568 1000! len 精算---:2568 10000! len 估算---:35659 10000! len 精算---:35660 100000! len 估算---:456573 100000! len 精算---:456574 1000000! len 估算---:5565709 1000000! len 精算---:5565709

  39. Stirling’s Series阶乘估算程序代码-1 <? dl('php_gmp.dll'); function xfact($z){ $sqr=sqrt(2*M_PI*$z); $e=pow(M_E,-$z); $zz=pow($z,$z); $a1=1; $a2=1/(12*$z); $a3=1/(288*$z*$z); $a4=估算39/(51840*pow($z,3)); $a5=-571/(2488320*pow($z,4)); $Fz=$sqr*$e*$zz*($a1+$a2+$a3+$a4+$a5); return $Fz; } for($i=2;$i<20;$i++){ $f=gmp_fact($i); $ff=gmp_strval($f); echo "<br>$i! by daodefact:".round(xfact($i))."<br>$i! by gmp_fact:".(float)$ff; } ?>

  40. 估算大数阶乘的函数代码-2 <? dl('php_gmp.dll'); function Lenfact($n){ $a=$n*log10($n/M_E); $b=.5*log10(2*M_PI*$n); $c= log10(M_E)/(12*$n); $Fact=$a+$b+$c; return $Fact; } for($i=1;$i<9;$i++){ $ii=pow(10,$i); $s.= "<br>$ii! len -1---:".round(Lenfact($ii))." "; // $s.= "<br>$ii! len -2---:".strlen(gmp_strval(gmp_fact($ii)))." "; } echo $s; ?>

  41. 练一练:用丢余短除法求出下列各数阶乘末尾“0”的个数练一练:用丢余短除法求出下列各数阶乘末尾“0”的个数 • 5000! • 12345! • 5!4!3!

  42. 四,幂与同余

  43. 带余数的除法 • 被除数=商×除数+余数 • 999888777666=9876 q + r

  44. 999888777666=9876q + rq=? r=? • <?php • dl('php_gmp.dll'); • $a = gmp_init("999888777666"); • $res = gmp_div_qr($a, "9876"); • printf("Result is: q = %s , r = %s", • gmp_strval($res[0]), gmp_strval($res[1])); • ?> Result is: q = 101244307 , r = 1734

  45. 练一练:乘方与模(取余) • 81500除以5 的余数? • 32000 除以5 的余数? • 132000 除以5 的余数? • 132000末三位数是什么?

  46. 乘方取余 <?php dl('php_gmp.dll'); $pow1 = gmp_powm("2008", "2008", "2009"); echo gmp_strval($pow1) . "<br>"; ?>

  47. 数学方法---二项式定理的运用

  48. 2009的2009次幂除以54321的余数是多少? <?php dl('php_gmp.dll'); $pow1 = gmp_powm("2009", "2009", "54321"); echo gmp_strval($pow1) . "<br>"; ?> 答:24770.

  49. 欧拉定理应用之一 • 已知:(a,10)=1,am与an的末10位数相同,求m-n的最小值。

  50. 欧拉定理应用之二

More Related