Skip to content

Instantly share code, notes, and snippets.

@Enapiuz
Created March 23, 2016 22:32
Show Gist options
  • Save Enapiuz/27af8310f328a9c32304 to your computer and use it in GitHub Desktop.
Save Enapiuz/27af8310f328a9c32304 to your computer and use it in GitHub Desktop.
php-gmp sum
<?php
/**
* Need php-gmp for work
*/
$numbers = [
'77863642434703028237682634582217333171107742958891',
'13803248561193268352849339467273586188719937714737',
'44224983195978765477621123627619455875331891277366',
'73511507081351792462717267747865554333128690239000',
'60324370364948677674149720186455490261314507157543',
'38658652098481550058146195491551973153825229798142',
'69623963070101103749258802415169565724905351029859',
'37259402863455231272310851435812116544730805965693',
'88774827133868236866767036121356295718170192321138',
'47561586059630678217785862571389138584700717179502',
'53148987390179511233800899119857356228784114296434',
'96400647662712822460974852837922165554701171302919',
'93051917533199032732655539302302980496274988392495',
'85297468236319750504998242663436240026601445643132',
'73731480855918244786449418044788911042423089255261',
'80619196248140283697952359118078200539549380507071',
'29752011831722291575226588626700655410728493838431',
'81169633422261201402691256351038962761100078493033',
'41782298779882471916935679153198204891064401308462',
'82266935981151687651985364974517340887122396032094',
'16467247036155326941268448499110052178886534311479',
'58808332517329096948403103103160017064578882277575',
'10520617944437898388952577604277516939837867121253',
'44499586477100580430052009055593704566587288807601',
'27599153019834226572011653863940339919921509659168',
'80918398045632279108221693736822455677670073844674',
'80307982011465877471538202592054463253374035417635',
'96564001137083435724695190575304662456730812482008',
'66401839842143358169217649130408534628920256801240',
'63493645230110918923809158848391968504458905242586',
'98158613184731646854608754802513285673669494264747',
'27227865422124526123045507906391762175841116643793',
'39850974894692494486368052068371819815910113761040',
'63490299853191179995399246673356287563758444418220',
'53154165762550556600954767900019986378970992788078',
'64797215974157442597089748525751049202572404302198',
'11405262167097524195464078289767857222196498196134',
'29687534751215212055058906496964672558760320501154',
'91133643125025140132825568220788949708373324718483',
'57376931880125809438719502505545465368409685529830',
'71223388766326899429481386092863529999034542088544',
'33995917053899725007399139847689566709529191189337',
'84790942271541382242627748059894973082898889736963',
'87206620190357534346248030013849556514356211899613',
'21043428350991221189032210186899219729536503580454',
'45921258692976503811486552863113407178171167533442',
'74150896154954863910644978643565912769523517994679',
'75951901206636834598184405124056408120655559297841',
'67644459127085238805625953993846409363249489129468',
'98499869120140979681802667136467929596221650382127',
'73907675497041137141887536315127577976650808741634',
'54192521026103408661173368701953261361195486615212',
'79435343347066625586018352353537660649186444536550',
'70517728982618553879543271828187149743971001556862',
'52973321283417716122503456539069424763416261020226',
'50641658018819365611278644990768554434421999162162',
];
$sum = array_reduce(
$numbers,
function ($carry, $item) {
return gmp_add($carry, gmp_init($item));
},
gmp_init(0)
);
echo $sum;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment