Skip to content

Instantly share code, notes, and snippets.

@film42
Last active December 29, 2015 16:39
Show Gist options
  • Save film42/7698382 to your computer and use it in GitHub Desktop.
Save film42/7698382 to your computer and use it in GitHub Desktop.
Why Clojure is so dang amazing. Number from 1 to 1000, applied 5th power, and multiplied together. BigInt test.
(defn power-of [x n]
(loop [i 0, acc 1]
(if (not (< i n))
acc
(recur (inc i) (* acc x)))))
(def thousand (range 1 1001))
(def big-thousand (map #(power-of (bigint %1) 5) hundred))
(print (reduce * big-thousand))
;; Result => 70797557287071972095635248909063496210728842136223429601727363801156270121053570859776123393895
;; 50896946808575449528050422187306055620702004015262869137193048380698306244243552927626960281979
;; 26036364028129598217199743449625882498816710139610604976580318820255402302215239787195344569908
;; 98497524611639355448214428666392937258266848056923349930354923005810546113844831345782857410933
;; 17862442860620960835507844599215226477436024147950549004249121475945618121991987049895917055868
;; 78086232050031371217220121930537634594033475175564883363292683191537418072838591606035717884106
;; 24300872845498091260352630671034662499180195426200152625285378033867426142495060217539056841774
;; 85824000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
;; 000000000000000000000000000000N1054923848976848642067159908827399599607494918798502978011050502
;; 98824646322362566791123644175393215708042909020894872665764145155812434193247993356389574712915
;; 54124458285899343675504825893783758670066452653605429219388817212949255016509363929528516495216
;; 67707535037578426633322850636536698686594599555364894143002421665156081851637526222540524931295
;; 55676274213268973528293671081424981059888505479194572844083070851207856202410776106230449968096
;; 55460283849134460506229083432264896039518342871604147789546415034736832919079515548958245667794
;; 42973811920586790521701243312844150545798017177222715119266690020751715086122411869008711090654
;; 13520010377891748628043398980176552020679258092759852891519798694114824131107774887067762377697
;; 42272175858900358607209528287159529031384888213634581576989642808187518632874356957698364305545
;; 15300610751442648962525143415329642385376413520785430263682369568606071927411937662922507543350
;; 41977935271880143167988526614452527145986661654019458642459165326639603012846985555833342266821
;; 49993745620845777633139173251208737521692392492623781045153302026735277901355571324421534940882
;; 66820865978228243625981446128493475758221295986408360073704826401838556371049529880300289001760
;; 46483513555373973485099635590202941812736573464085289835186884358514570590870127913237247988169
;; 85064628253585196044665242195341740225871272113775950417329975659522032497112187457057599889424
;; 81059478495194478386234320587119161802816478865366748060091411832553679118659090409160318298129
;; 58786871588790723232468355401365635094097214631182404680108179828075373679260940515595157557845
;; 37198249049572308428716687783936203418670550869259979809579650636969950919977622088118794547325
;; 75611022530840304335596965144340381477746072824811524835765679677005688486264262398378375105301
;; 08945819094811532228994045050334293753459729391215163817299568459706502479211896044536608990641
;; 60565912419717181443485938719827776270430088105190854455357783037234847918820403600036988727371
;; 32728729808378225928518949916417434512061280737707116307413750487611414826532495915134108120780
;; 33936254282784927159421886700070754159160659491488528194281886709435215666960472015421562949876
;; 21159489904128440254435614039601790044991840989577617921251165007862733001352932321539555944212
;; 23777309389573312114685597590470176517260319161944345659339657074733403186165083785473452113840
;; 75554121913893374247317217010891405880573906164112101521540554432554564279909192682585348450392
;; 41929738162921525875323591612960494725932538302667810674227988608260691136170213379072117742260
;; 88533175665977991328073126159822669685041369502100209736103772680954463464628355583833308922357
;; 19045739109766088110295096800403196476746165466763546221293652450494932212046152456443596206157
;; 03825764713297487704902223555929999783332836663235346662600429271563118032969424339388415383628
;; 30832839356174654771805603454422024350236303859345294238858448144385535157492549519982222047015
;; 91585083997007169170318252944655080181903514294229216016902985317066962574819735752210284018015
;; 48921743042675662133977546684912565413521510142298677703756258693483914667903794528218067885318
;; 28073315390655708617045448633864740841777076599039880422494556963524109178274103702781864814020
;; 99856772213745833968496507144930134175350668191966255727676922802943068901895938334915426215616
;; 85260027315465049342003344370868329004275446337997624800058551460611206768968650514457715783355
;; 77724393227431855747936308636668509405127532112294155141675233682110132197818382958178226777383
;; 26724274953522660731538530793923248976285444961365709109004612388360997140457758019599483440892
;; 62295551126924784325073902175798835725112442047451859883220113649731770366479029008760979276828
;; 78710097974443933409147401991178061709740498568252441980053917994727178588763784579214038572181
;; 33402895619093418324802022566953429828121852105818969530140128479948640249743823135327608441235
;; 75735438503206869228800773581740310286727480283878523434303877850807987402298646520973526453718
;; 41725256497009939891139042378528876033485126214291969933408417438307993574937944458599854841148
;; 90344686723381453788417596106331895687878759230567764394649497845915935776226743836580825734516
;; 08181215260749755487826751911306759423422018486376003763828698728850850418182707024419737345351
;; 83272859437286064954639960900286888259208544336891488958012223014918075190344062814500395501667
;; 79853528978820359477463967535392570862347019161974632040068165388651826337967828281087081684204
;; 00579690639464591838490747695425095031629083305007066226819263081966771561956937554770018759099
;; 22888373864866644268749751186107960009641336187274907604225353126370043000760534630799023302943
;; 30268584179968600895331607585726676520171150951754795427082028969001822475211732241712050543532
;; 36029529697624329580549928572447407505230194985977400828998871242510679759860932169820945009518
;; 31693379470369989070370322449831132110315930075606887034117596156738699830290467687698499563032
;; 91008771041070311528688175820889314101903501161548405835361328235234429007725579063286383828523
;; 80646446827428804262476849044471376458342264295625860258665372804267608806406212566797352081254
;; 82984404436120436273817900916924588979816266175580119830107227056174470592986733902322832904312
;; 29622266153092354543763334768267360118324192055307680102532356133306801626595705990213610742473
;; 82798879506935666239574140248196566555542610440667353583613403312054862782158550661409786846196
;; 20385568891488277933853617447481508342213553571904647843017301316730905998888384323145169972579
;; 90543297898196870458808289392665989926454893071118898512601403505822265056897613885095984326082
;; 95872595636286303187827087097406010558763557657921792187720967382585595751993590092488185198718
;; 15819617462506629771623913246875445993179334062856707621110063356839652640797529410166210874742
;; 31359465247949385360180696422303239902982472582100657623732575858197662095651561397332491954531
;; 32078526203939605793333002939796892637053581392591464222454764718348499860856509676972671579051
;; 37930159651324602127477693169286770378597183794517017502498587683521923797534942277998188744089
;; 43251196566496603709956709695426937180592890230940401332378125202521939160876462552578844505804
;; 13814634837008345522179950220990813722994547571284293999888456297116398311475655094487213558610
;; 31282521897083453568364870492157909521606458145285494526427099444739242334209675035910446034961
;; 40952616358091596074732393478772970096243711840097916561382424209640956974923008083973507742268
;; 05229812826889995058837997329393772762833872392677317694422826481681211126788177956303210838253
;; 50158727360841817589150447758079186501862189084157245488652402121317588196814317018912395321465
;; 16438670632809522001146138223237941694571658012224843863075736612008217527570332822718855146524
;; 68296545058387211916425896514988306596763007570656548255317941551362249389215593044354272609986
;; 79591611764180296278437543253118231209294313857926198805206411036521604321567043435723605052434
;; 76085519707336310126861955896202177671628822282422824281933103917194571230445720105945387003153
;; 35820011763512206625477649421293287242960790296006339790396210938472524692805271003160364067716
;; 18381088184100189093453763197347644035673827705105476438325825195713308058540285394639750169498
;; 54207587636294455842126784138974944658660475250784531801582102212021374912153792771880471695522
;; 08989434449845286169783114418349205156488181509171092054661480306762925929766099508883575998825
;; 17380969073304392047262144078013564570859341040217407857361110895569105195060343239034402220249
;; 34027226066582494934642811714404700204291699650315094671246204257538263470321949481478759787359
;; 24952773818654120519833507076511942145032495564266622645122412743786747945597598752529134153734
;; 51363264700976580449725911382066701606422468118063268935783293985666585734832842624163563113906
;; 83030923730391091786116600637247775705612804218705606363346770743720016877299305156377208621180
;; 05011847932769873788599333699986564885479542717375165868477663025915621552176766784455418891674
;; 85882717381016040015177231306521181644746971975160930831988701303915695202058186037360216248290
;; 73841998241653150114455174187073506844409137792617519120546872456661869380961798949540054043973
;; 58082434432033095850943314858409319507318153387382805737127081505198416934628916457140519588849
;; 26745523486614119467628768546173692201078599772222896982340902258735882415425670115338696911518
;; 18124533216013680833734711342692597089181120794887579387180027223313432303410698876879136257758
;; 39009065680070837284510166701304366929414554078025291190890626889477188639997121042275070869228
;; 17409320259760467885343630829609816835382802883486461417980683046726439039980181763937577580648
;; 04862270615083272762166823230149962369290953304424686051946086540539101684404137765049798162598
;; 13626493343179545885916780518560345134684556637010861710419038829841256429497667383227798354521
;; 75279058859063002606532359926121715725273976218912987369483301957281376101998713096579873169189
;; 25954136374243586551215029644793359793736988953728934195809030198272344213518782918637188774704
;; 74478808507636693528441913760553523556106117638298588981249382380841932482971985355846859810711
;; 62889014092404619010996509107034258447685960653437098042391835969088951607672917895553185047350
;; 17821612118973472638596200650209382220061222661065500945366038084934382297371942333291993654894
;; 61675122685946338042350917347035843943127871181501817726959528416699056173039865442169952821982
;; 44322832663047563773626065827817623697107871598155621958651432650373880557067001215421415219956
;; 84665807045436663804291236255872158077649282682132636463375905788560851624902778059590331200748
;; 39007136415457137252818564702530032707578961283263045410949327131993538368430444481496444439167
;; 62802863033787160731664057138460771744542484616994911660206342011036145549619018327471302745201
;; 86128651894344596671845361092736582482356418008080512727987407833727928241257266545687742933103
;; 55469263155792189983281323089479807274046906739003373967441652764664231643973091844552578038750
;; 00360453213353068463904316770202334540329650419805753791808622220862283277891913451070408775464
;; 82019511682572100094235911487302426900219194418677693155423934749425898158083873886328079200199
;; 83581714987794991145318698306469125340697044961393042927021915369955018724710056320665673858869
;; 41799001007114986837026733766943327115198980220104294651991601892027085553853139829257905822474
;; 31300762763406197947047087806927432378603462512662884034013367749429600874129577626718589206542
;; 77026662251876079384998864646430038221405402491737023780859787534106906723845869044217289755140
;; 41095164838802143779471735652675847836134667030986548982428345751496367017326164723638659169658
;; 22891535422668258597532371650455970935690468452482654416230651078129193157969850443467111542912
;; 52208306637125798043577561567375260740363414618901807822264927213571668601796594782375415395383
;; 10617183801854407863846979125355624939882251118758546498999836480370967331619753405265203140209
;; 61336531690859134851239941889567644231292483363154648418448680149757958762229083155752922354219
;; 90062990782633716658533366821454431271022835250868845659184809490782359087963542792994442534647
;; 65205581159595267075354115586688619806605485882477706815922904591777372682805766989317952963832
;; 71341157993420739521672579665216167291373268373985255581595359992389945766598067707271267678023
;; 04562211394153251920189930963957472531707625243433730074465257525473090865825205485615420878198
;; 73609464071136528357300300772023735071307711028521983149676297613104493324761118949448567648069
;; 59116752922158014967259402566831328893463116313848512910281522430756258724066562314649315151127
;; 52068123964950101807653585139269632000000000000000000000000000000000000000000000000000000000000
;; 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
;; 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
;; 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
;; 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
;; 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
;; 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
;; 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
;; 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
;; 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
;; 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
;; 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
;; 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
;; 000000000000000000000000000000000000000000000N
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment