28
\$\begingroup\$

The objective

Given the non-negative integer \$n\$, output the value of the hyperfactorial \$H(n)\$. You don't have to worry about outputs exceeding your language's integer limit.

Background

The hyperfactorial is a variant of the factorial function. is defined as $$ H(n) = 1^{1} \cdot 2^{2} \cdot 3^{3} \cdot \: \cdots \: \cdot n^{n} $$

For example, \$H(4) = 1^{1} \cdot 2^{2} \cdot 3^{3} \cdot 4^{4} = 27648\$.

Test cases

n   H(n)
0   1
1   1
2   4
3   108
4   27648
5   86400000
6   4031078400000
7   3319766398771200000
8   55696437941726556979200000

Rules

\$\endgroup\$
2
  • \$\begingroup\$ I think one might be able to write a competitive 4 bit assembler (or even 8 bit assembler) answer which is a tiny LUT. \$\endgroup\$
    – abligh
    Commented Oct 5, 2021 at 2:40
  • \$\begingroup\$ oeis.org/A002109 \$\endgroup\$
    – bigyihsuan
    Commented Nov 14, 2022 at 19:32

88 Answers 88

14
\$\begingroup\$

Jelly, 3 bytes

*)P

Try it online!

How it works

*)P - Main link. Takes n on the left
 )  - Over each integer 1 ≤ i ≤ n:
*   -   Raise i to the power i
  P - Product
\$\endgroup\$
5
  • \$\begingroup\$ I will accept this answer since it appears to be the shortest. \$\endgroup\$
    – Nirvana
    Commented Oct 4, 2021 at 15:52
  • 11
    \$\begingroup\$ @Nirvana I appreciate that. However, 8 hours is far too short to accept a winner, as it often indicates (unofficially) that the challenge is over. If I accept a winner, I usually wait a minimum of 3 days so that everyone has time to see the challenge. Additionally, we discourage accepting an answer on pure [code-golf] challenges, as we consider these challenges to be competitions within languages (e.g. Jelly vs Jelly, rather than Jelly vs Java), and accepting an answer contradicts that. It's entirely up to you if you'd like to follow that convention however. \$\endgroup\$ Commented Oct 4, 2021 at 17:15
  • \$\begingroup\$ Jelly will still be the winner, 3 bytes is damn short \$\endgroup\$
    – Wasif
    Commented Oct 4, 2021 at 17:55
  • 3
    \$\begingroup\$ Tied with Gaia now. \$\endgroup\$
    – Adám
    Commented Oct 4, 2021 at 20:38
  • \$\begingroup\$ @cairdcoinheringaahing see, and THAT is why we have the occasional "ban golflangs" thread on meta - you can say how things should be and stuff but this is reality \$\endgroup\$ Commented Oct 6, 2021 at 14:00
9
\$\begingroup\$

Wolfram Language (Mathematica), 19 bytes

Product[n^n,{n,#}]&

Try it online!

also as @att mentioned there is a built-in for this...

Wolfram Language (Mathematica), 14 bytes

Hyperfactorial

Try it online!

\$\endgroup\$
2
  • 1
    \$\begingroup\$ The built-in Hyperfactorial is 14 bytes \$\endgroup\$
    – att
    Commented Oct 4, 2021 at 19:27
  • \$\begingroup\$ non-built-in 18 \$\endgroup\$
    – att
    Commented Aug 10 at 8:50
8
\$\begingroup\$

APL (Dyalog Classic), 5 bytes

⍳×.*⍳

Try it online!

Monadic fork train

First it evaluates range of the input, and dots the power and takes the product.

\$\endgroup\$
2
  • 3
    \$\begingroup\$ While not as nice looking, ×.*⍨⍳ would be more efficient. \$\endgroup\$
    – Adám
    Commented Oct 5, 2021 at 5:36
  • \$\begingroup\$ @Adám nice, i wasn't aware of this use of commute \$\endgroup\$
    – Wasif
    Commented Oct 8, 2021 at 9:19
8
\$\begingroup\$

Gaia, 3 bytes

*†Π

Try it online!

vectorizes the operator on its left, integer arguments are implicitly cast to ranges. * is exponentiation and Π the product of a list.

\$\endgroup\$
7
\$\begingroup\$

JavaScript (ES7), 20 bytes

f=n=>n?n**n*f(n-1):1

Try it online!

\$\endgroup\$
7
\$\begingroup\$

Python 3, 28 bytes

f=lambda n:n<1or n**n*f(n-1)

Try it online!

\$\endgroup\$
7
\$\begingroup\$

Nibbles, 2 bytes

$*@^

Note that this problem influenced how nibbles decides to use implicit args from implicit ops. I'm currently thinking of getting rid of implicit fold since it is uncommonly used though.

     # implicit fold since accumulator is used
     # implicit range from 1 since there's things after an integer 
$    # first input integer
 *   # mult
  @  # accumulator from fold
   ^ # exponentiation
     # implicit $ since need another arg to ^
     # implicit $ since need another arg to ^
\$\endgroup\$
7
\$\begingroup\$

Kotlin, 59 58 bytes

fun h(i:Double):Double=if(i<1)1e0else Math.pow(i,i)*h(i-1)

Try it online!

Longest submission yet, but thought I might as well give Kotlin a shot. Used the = format for functions to eliminate 2 brackets as well as the return.

UPDATE: it's 2024 and I've been golfing the same answer for three and a half years. Along comes RubenVerg and absolutely destroys my efforts within a minute with -1 byte. Turns out it's a new feature from Kotlin 2.0 (which was released a month or so ago), which is why I haven't gotten it earlier.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Welcome to Code Golf! Nice answer! \$\endgroup\$
    – rydwolf
    Commented Oct 4, 2021 at 18:46
5
\$\begingroup\$

dc, 24 bytes

?[1+[d1-d1<xr1-d^*]dsxxp

Explanation

This is a complete program, that reads input from stdin and writes the result to stdout.

?                       # input
1+                      # avoid H(-1)
[                       # function x
  d1-                   # 
  d1<x                  # recurse       : n n-1 ... i+1 H(i-1)
  r1-                   #               : n n-1 ... H(i-1) i
  d^*                   #               : n n-1 ... H(i)
]dsxx                   # define and execute
p                       # output

Output

H(n) for n = 0..12

0
1
4
108
27648
86400000
4031078400000
3319766398771200000
55696437941726556979200000
21577941222941856209168026828800000
215779412229418562091680268288000000000000000
61564384586635053951550731889313964883968000000000000000
548914237009501581804104224704637116078267727827959808000000000000000

My machine takes almost 0.7 seconds to compute H(200), but it does produce the correct result:

114256002424540571298977792354054343003217988447353197803701128087779\
727310773544883222069862169886712875089569689613436517195625058699339\
831616247967378727547253765461789388643475674400611735920545310021028\
378006078740483920058608872101517118552137511462765664553099379243826\
960171887170750794198373595289872526218671094534622811250467573078955\
097722440499909299236803909456886903559422482755722874996888761181995\
575299415208051459908113833797191408981585936952677202993799475038316\
559629150663378834397372775965856682894873495939410259095804412984759\
376802645433107086846121910224544820403394942396165166503784543183923\
373316267239065885057694972898540625272750046246522113004186914354002\
967536413371473458112220769020094756837578527902012213205896270144393\
863599279497755781359466901673079326909202551645285985747551170700716\
842425698975536766498808553756048408306339794216494138288030784286578\
757511579359563917784149939178533514638276262178221710320662541522716\
166268310550789650887610134719729891484651131282509122835031254510412\
859215509732637002095449585308892098589802359045914197581197309643963\
042570582527203047381981490652454323893038445041694758990588984561508\
024977520153869302479414855203541538559245994267482585355022642863859\
784222422005021616964777696793772349735028255170680455712484791660880\
381133647422166704047722699070109094074510187247343055332257496929374\
982064491045838594959100552218107373079642910265887514107042314387137\
231583168255471546888411138370063211060324585902513206145493958317539\
840648935101056767774783896580016743810934173275647035655085909723344\
400585286826414068777563965071196389690941135698863589037499407785370\
931798703443963281315725441703395909623807818562899480337755459429222\
263976154559801703132418440141220192063353095047779835936440544198953\
496106173470542538936478118001519398934406367850808122800102137273226\
951723289344106737093183594520201847490204826536442751006791251960765\
409736570349501810834880546030444722460505622335562771218876927864732\
533831989277488466279926764165356648286028875357501991394907871736473\
399337480995325006099531629623628775557151039011468601336589825839738\
631718648726576082486937471392562052316112813773965598704019732181766\
979636498126699138316658703065343361486555049963171513229287190102366\
294038070909517003192684859103788524924734600167422726737999487560861\
040910125441478016464932490390352767808126453168977619717961242515337\
678589841167345358713873500430963639031923908700261694508782150681050\
006111529466925629252138641356979249757548377531461415227595617743646\
019706623647306680452085764528828628378729906162793797766057848324098\
880977726680150730390074716141211796155230858668012021940942979991319\
892197094655756666501455192326506825509530719155451676296396102560013\
841584265351485313695020472184192704099107932797640710173835532960606\
518538605516574602321430208034314359982648827905481627199797808702727\
344458806167205608568625797981988480548489292548067131307825217362115\
487277151573038609637079476077578954700658210221211043513144482137132\
113794287001433270940578127570053434695653912547579202493901871464470\
764410974150819235945558607363556467922279391141836922743541233760821\
871365085257243448039467666652724537269128483841450819722610910449669\
667767218934240840176992473839442233550613463850853485560398554469357\
611537501209062167152021399590356213475289096528949653047033419077429\
299028564676171187099901772701404490557158793484243417114875079809449\
627812693323373523747772814832161656651663374496734064538978915783865\
719064174822864696226655708942852177545994665514849721267519945794503\
019098476165255673401283399976325921222555982464845071082560857852257\
814145566478967899059920204170727945409097495154492869672134459786294\
588119159908191561922643839816897827104225462279731830827250471252105\
289727169676968836275320004859466161656331082081074381176816967370602\
357442772694553727911750007625712888624429904817070697897964886832493\
345528030314492840383966128843659735252693645758721744757267671336699\
697149807573431757428427239466529780150411631632066022100098544057533\
387989402082327607683479023952713064900546185006785478600337149539296\
663361814407606344949829339294479920368454331595871231338484805775737\
339268396124977267103545541977669058589689418363091692719790628856414\
752071432633359549389607990792617571221154257026279901828952182073374\
160861868734416746968494659933958156742463652295106500468210780119125\
220209380290875380832470409648848082808663586942813054685601333888677\
903229796350639694587698272283080314334773653111218034106708436851163\
056715554656438061557864316343565021443951504379532417965485201636186\
463813912432724675905548790267512971651098333554063940806626704854532\
678674167073399666603479497096163139406079292169446126287164855437310\
733645103657687054384245612640135453530729419221334723538721255762469\
348656691594173954864816605371367857438364854545334435452281244641153\
702780834293385080202596856941397712010881729069210455124793116543955\
764287224835926198843406678698041913931641907309743017824157088832657\
515931712589921404995250184506019056203133181617154100069201866951525\
300872664323283710970049931600220543834155799207559964184227001086729\
978318247276684554857576596547291291791522751007585853793360225113135\
450501518599762144278325251060114811491521595770223299394208499421070\
133134002376834102080109021979719187115415860089714599508435221834288\
106979134790461271826466644755668937746875390891835581995388195707703\
666919259484508094626586130500902421761233473185812236823727560637765\
353284587005782503482049179577624131003496831794473409129318251405306\
686312023625090599797707676764002997295491901065845799891148513188011\
750255365930732717166438760960930254270355434958193721008813937013342\
442685357933848612269061232591941511207731095268816549202309436856983\
863709498625968309204249579255954213842990272453525630818763597799543\
593087313268427793519216838584166922708627220843209392429847694078662\
627081045478537054881042974186251081449455396030353464966077751989172\
967094495553235926368816821576526232804884953832820814720565106292278\
677023212354425827714341638534116865568614053180685437672841412518894\
098874469347176584909301684501882789675804879960815875737873223894302\
068322229857523890186183543936935430404240034004709340156823935334504\
280773088422757352262015925135936299428100399162508993701323816640249\
317502708643002177380916843121414525377166307214659890456197078789358\
755908958395704605757659385312957851526639927217127812638621838046618\
256249655670855709886714485145533985086443137064765377391996261567764\
614649944571049532129160422595979803302687452962711606329612008212827\
794401494192040770665411078681415279435060816655175330979102977082874\
632330444354061833803759173996116082517816249241467318683953133297949\
696966800597273657946143827878859661836812064102045501830604467916228\
427069899293175548188750078304435399590540700476604483395383697312578\
097710820312329606242276447140831589400706797160881537904137892646388\
261066966454548869342350130453494223912785614903507340787315001904795\
688540272824396638149906352594040357284385938277509795452746883194274\
390009993333838096016899929412160162615538212444522338199878096100853\
638701901085648519985630176886727084180895587065782329076867465210575\
281386375663556976026065633532489743239889186305075304808560243262432\
658085969412020827902073591982408638009516334902222599715386120602437\
678310010096587347186053193158239648969456170841664624039286167247669\
514436308002065354268316000349861095951926759431651589488622884486382\
277854033455441602586071384379537383305706042265499575026224506704860\
688406915452474511683218154440889210555179680616817271305312473155544\
143262273531331795805472254371401019589348634412412286987413907792718\
329915124784729596566415082748529970796499261705982501268401723583887\
701661443797764811659857704733113125011378104100970585073283674392976\
859476816730766230843992524449084734798618995888731548845560723062966\
192859122943220390909175950182057052843622022554828023378885550828117\
382718195394157370910647482474167099695486548360631460470999045477378\
132717331452335714187924997815103638622262298849924210205241176668405\
490741524219253278664341011210099915988552406343854573062664870584245\
103886217277906440977065037168659090059763288778505082007530932618466\
494869181704099810631362022702089755491800061458537467852967380851010\
908862739733011423332473338496528317600181547938903583970178021411350\
504107353290656971578124200774189092891257270280529095290550988723728\
135603533746551804333320307013973767695324099720923379543683864817974\
710553868201698590292895333412491357784173524677821074492989035878523\
065616904294807445990638805797254482102285949882214670841897742949328\
311659987640881568459282440548451135162773664037389258355421285035420\
999699985577663763700005757941427315733197266168699581396576204803981\
473126870934075898120336661598190205939756443947057710182924789850055\
001425654550118743113257624420824183938997656885814673594734917916409\
078995498945642404630814171603046441105445059249548610322842910754951\
846627795460490833776103956049657955540015291032378840531042472594532\
860423319860149058941766354088020712438608204454072807575885575852839\
180700772630347090579280688794361068997524503617691544202365939291565\
645671286667544529026174876789733907296960576178709446195376983454472\
164584703777117244823990537583736958740841562740244004026203727555258\
450538750500484541128688250020648123312909872053878444932137569761105\
646598390520596957373979148797644934213546809772428508682350740007209\
819026797315661258929751889448192710982091237434909749464078055542925\
758110822533573122134535676028907089176208169078890508131338313078120\
366292092748543956445763451239618092200751801948183924253225759130045\
402864771211838018815605401626689028050384789832787839775255721097218\
181110343132212865937413848154233885501099705968645937079387543236067\
419341630111614913910492435024464166688710987099886511583318895948003\
248879615736644901850078099348201377864691386256283320069993735388706\
880978227943386880372348195108338420348643722382324037845214076409223\
421605406326543434017961739452074663199250414741826344527959432512472\
288051981715822955586322044373144003885900746941921709703799672502350\
065363701967267734865903791650802227123544971675955949787985267374530\
847885039570559135088894718198400171730871289918834134265582501872441\
817474408532347174649197682421484732565030830602652775869842343897079\
665618967792517232732353781319861024635289426450784800702094918520783\
421946020173070856497710123531146795959596308032645673704792463483238\
508003336793688645287713354332253474988554262325815954309909567664567\
573258648500395650173170779959337702622396455572300230300768415812431\
943010715240963679596296486831129989681871718230599580037772017117033\
315832399335703122496145800075686154721432794663618613863892627375137\
366428360989986599340414088453536386107561090367699159184439260424635\
745591597059093633912447921539583960069923796416538679234874262062410\
163002664653721804674990501848569881038943775993261621385733027297067\
083554262375476401287244101149052235300084299630703460854961311971283\
087073208822293226528612144677097325474675212863261753395272291201243\
727063158190087578787154328368369458561245784693838304278572756604546\
510952636210910525436103646773871458339800106430023155717178920396687\
520423472846663370278770127553170373437626792023727289514355087037311\
140097772419377161850139650623158006220407602434802036169803932182144\
364560440183502624140166248069772217517658503727605438952409331108997\
938796887451122008271640565975335203086775806001724195485708936422425\
137056283019622940342042757720398404950656311129102072111491775765939\
145688292407278548040314549680511643911856331584703069002009015743434\
987416878546802024548849006779822873402507748917427021579312534569977\
361861231854091421381548376451031427272315824402714317215823133557566\
630570188995812896381696487597394215612003133922998761317879400375340\
125754172678973925934340294567607771195422852830929279465841874639010\
009888808918675285586746078546918806973510720653329464320497985376475\
514652191137288767301110502250694677101081566428326927525440430403867\
468662023769524677616162779798242348230999586692878495342514713764186\
714882538090458901781712475105348027738734745293498558256040405894803\
195991677041814864565397732062450568265762161106477446853681187477778\
726005451422916487453440941705450833165526732124577290035369815857754\
177651321505099564890184890808449589507960017238091650940272579801976\
012553611294392411698525056432475991421017871033115166544672308666931\
153046458808727931683807887236625749116358879625843911889493775696035\
689596716234107636539958765668585942904085430988801703856400119630376\
274574597769512867580730016556216727676744713487993170219184593464999\
311291112749880481896882356531818314812757939997704540854301634559210\
168428005707651884236890080120885190924260622549699781701215291431456\
641474519410935152273699234442085712020314906414846783096378915749837\
313543205699498699058727247319542037049467226655708039331544604104781\
409084183109899592118979816757807977852975258979779416901404268104909\
705348928232083022795123709882664565805802427977177013536930315406074\
119798700228696233155965389441167947547520301277280800708044768115830\
471568118316963537054375894947474149197268583279951389007580911096150\
587642304998165318585620851425172746769477143145386873345481245188537\
754898143742686352644071418948819336880282491363012186422360754575220\
279448092609828602552016180377773970908025714516279864286548174974082\
714686202892658851979133054341592863444445185327463440688040605716405\
067027534367643153032569517666086981280522416245349519983986846967214\
042882273846333605336087299637431797991108127634339718858236191873607\
992145012212007858822784503266193271141131224661074334214839250271667\
726722076785306858810448052589267984702881718156816842983856068663911\
962262395537169886395290931248461646122637458717832878921862044114375\
961223925897580056403294305693475540045578718469567147106404825130645\
182596807474482717319438314466506464297165104699880281509113101964645\
644113558063277536948464800478797709703629400329162780840501627821037\
796082859331312091625314594124914131496550405427389764417029031881865\
161566844591130624668157039150013878652923170474308357677476499519615\
694247353253258416153487129434125741231110906666192911231143233291672\
330355835909139214586207813893211012425324068478627916498679629380977\
726349923696052885626801312565943741488193855513659470521916364497140\
595263059255234991151676056428157949653159230890433842121335826208388\
342905112604728437774206247314145114208160560382868989175460790477221\
890350677890961281703135082791138001520406832403763549570484116412249\
411630340091247083693144122332355091861372457253352008769217588001288\
849717267814951643081139792036726924049299132057170441936528548540420\
064033867805971560358101657671048958681419753322017701206905396234428\
135916258956179250871059395091929250943571633006872870216908850580206\
492968748602862989200240660330463405184596960622742947121148050963122\
321259337631048134291686503286606869138604813871549760164086721913518\
637749340223861847791025891443679650627984525254307030025638348279163\
760184818981923247501359438277271636232964640495952052708147067280051\
510417155618166064646769348176921156031703472238576803756454461973221\
654819493213203649089803381920320331786258749203931226197991150138418\
412665064324591666915076933446777039262089089651109035566583869738578\
597506761075170629480218974597816082666310188595749958551973619906326\
148650712257007357155244818379632436183006582758626649517236510683006\
346083500259745147176189562743231550874298895062648811402347137583548\
675098905750258174262052682531224862649985350791958712521075292922368\
595003093091774703254502960834476169407594973424845628114251412090192\
033055714360450494006595575968666327901355614408397215867467966118019\
576690302025344757113309733262077331055580267485085990493403505787838\
624566370526779488899761016359956759522270200707135958413154679827569\
258052868584822095448301696499657831845970412520110100094933597023662\
316700009222296695302631294120144631256162943881147670342787558109037\
638373998645356492446988510858843413188523534457356161957326654858590\
170373845392894491611342691003506990032562657375834824358150900255718\
212803029008165248772179611829216450388154836261406465215609533903379\
234291823957337623177899123066407939187764831440259804897780532314294\
187768806308300849997380071853436999411397630694458010440206190084920\
364271955929368660748369995712502790615902991832507744246091795838698\
522769638481677935709999820969951468648542838681273677603394509504240\
308953934844440452041183172657724693700991437857142495426882365464490\
656305106674560342135144470557427634289016433075831708395587229518538\
740345784633830858370131443824184367717767852454910547209118651010344\
170278635519515658320221573860591898378883482625668496205501948380927\
655730907380466792089697431597474868907457592287486991817027217936644\
429039036949024880832634934485778971951179199938014320341094585037431\
867897462971290143952624609863752298357851890137576299456918192514413\
801163490330448708940809800295269673370776121695018917895759267103596\
712356385972690041695981952213401668647553788833494484654483704349068\
176379519514076345587421597137517924620994702202104196503077589303867\
675313731830281021790349204147751254681000976845402199926482744440837\
651540373296876407741833859447282118791613435919658716973720823338943\
594717898120853679633629496999886962089450217817683016051641978808086\
090736723556850600235255229245277419993691387427177263341235769365551\
729834695110679831584857749889217164198358411783052421365582162149360\
307993926083432465922185547437809273782150112676800043051133743848179\
507430041789107391336645174236054478492193980551977769361095960852905\
792648589491408260015780133323805313428641785267726788361163481200596\
667926844213028421995386505994266261197953159903842353647124717058462\
606195804456403148297397645768181232545874395373205289680341525417879\
379518455846428797752945668078353519178914505729375052075208668206727\
272592661778659138782753383579531751393302026177424043932380082134112\
304097178637741662710535952129056797743416787671115007825195113544105\
800414762132647003564766945538753743418953135801326760189012574025757\
396710397610011038820702402557513848062197209126418415099387964034761\
398231093033942795839030074337011701661581636846153029980618680958260\
742308998894462132581019648670875157214719847690770798407251574511107\
814179573150171473104112574681707827850658431097893612857747330174826\
263221914068851894736118756496739125630025657215461297066696668503577\
183582733041405309694827396016703300218438917954326780070156715389166\
252811797028538773333761911582321084851330319089805968859787814026573\
646629476563087343556603423340827325523779940913099871860140934516188\
332561209093937145532655355122173625611654611354926043249724145062395\
052073403358582466376317856821760549451408367635975857240939403560193\
544160535875531196735080632931626952143747529382108053685709281128550\
909871592283732369684212053409742502659002594127711109142543712695800\
964668096317273980595863102507908763243035048734467097315273670192716\
453090615295589332917732324135882790481157233370637919417730168802570\
745512158460173430843355794887960375318350278147166774927332518782329\
275386354748592633069853120237345941910229584677639028790677553936767\
813561547451464211027958830776412462906122376937072679758250598400339\
993262606250183184159965386752505918305062458782151287361652904255522\
543747897277759806217530894994343172655413398182581681612121938496736\
246719088985499608274563513876622367779465393373781088492229210720940\
639881067172035481989280366082376941532976834093527635529401514366330\
480920065589598817482347629673178135543148398941148123840436738906568\
689721644562620605431787705716472884630393001383812923459261978914853\
520746731592548434175828751037428755037026486707839111075059327125186\
760809267843888455412978048743136553565305004514936125754311545290038\
133113476411189830181873166563424701146947953889262645190552239014423\
479186724429640510640861075472230063648938881018870060968494482689516\
470150615336695757696184691763777764571491211746536525826581200382784\
605048388142804433635261164053724449418044162892154965646897057026861\
825789232153560082382586610167238788922139435234549283511836608514919\
974792081235167878301494357826304603864897832044708820907368556324046\
004658209312689805738179663008251252674020278832364456345461955022865\
901541110979739876238776312716778351664263063148749685831874832132016\
935035662777717441736545169081531353892410317684943418619599602983211\
424184625311114459460166018052595314630063133375510973311332443179025\
430071437113318883337924946520194725946143840301669209247618491596869\
860173921931370251854462447254511938184185608158210889650209973353848\
709587977807510498484825736181853375451441884380345067688458992092705\
201032496281343674420762320800084135089658792761869184762558806726676\
722458885523590174826474588896231438620097505667947655896718595462296\
073149666204192795203339103128540827107637425053771608250143437698557\
563602741277179793953927426431484612463294041151573622436307805492181\
876291160640064431719636789472314597957573238616645867471630699310482\
878202680466808957828942443566435405022152223504211815437604019790140\
352872467602517381951971882961416597409274884152966514052697974929452\
665027793695015778955965479075442935816241693073367882618572751594589\
233332763571199270073344864323556528614492269184498420264356194305615\
857727851288186636797024506940862150561080428526864057887939002534833\
217825476912788772547258529042674975441187757934184514203802802167837\
147392045462453011001438365392835225710572890221334777983092342949532\
868689408224926079952260855610448736367597882931687183102425507238269\
350671010537707473483269683444914211617226098220802284536428111841021\
355314413825525092408785132949971412943096362996439440725692261405299\
307258200399719962027229993095100541076413611352139497423587018295295\
733263490522360083662929196544565837957602047504540075089561711238004\
034860643130645844174467891334579002129171400079540258966611530625073\
574579537699621459654573062084740258612527512591500081306982149777410\
740290148147295694078336177308080249486577913410339219097486516457786\
845544171494564298759086142864890534059376979463906901088806630448353\
636096572871854504331730452532484411175697139592881541769738473473501\
712004493344258375971665263709468683587321755927947969108354410237014\
622630703966864710147906778218511531246507803307199958593420532473567\
565338941629308172125890217096302195764174165228707151304339280199397\
308288128401592847641643775412416310732509438568791320603475823678213\
022091118173309854694279041928766771888599086244343677301891998549396\
563784328741226437673040978842688696069460803264848555813028336564909\
915911729088504504385439303693869743774004188440858489234825773966439\
034787945703214397718612107720992665600929489208194882429934865386410\
161115173865982683536124076579147099148505092826111112162726946323923\
139510572435234258930966885308790903440842746447356148569569613011866\
216181017947765400323520849488099226865879685849795232175081223157195\
558113479584013517247486158682510281822439736394004394576804296311483\
351867976357203923346203000720371078664247477194715030805264065168164\
569150139879569137943947304661266767151775830577387052301128796128178\
850612741616402622378092347975800584931763715144855238926949360664959\
901934960478488277241384228916947176273846643398938259717770068619213\
014487628266764663292361016953761364719861839113749885418576027074151\
042227017329247056848702075777200168698630056385228682662050087522766\
447910673436514156005878826955500834129864964744197436204252897718702\
140935816928099490760288979327872784783800062445180868891140814201746\
324920232428770583016061424533155666267075515886721407197157139617172\
925490167869130332346357795391916572750248424895052516323326428107724\
137758314910463829058203923431106387112309788487602414624710825158177\
964114057894343181183813244756477920394161657833992924683207226012989\
176214196381796431783415316737367036887146793201669533134930615758349\
947223575783239017366550781734221690665045190947669486016226383725404\
770500226241189927619067594575715556154029052556931773345332242188757\
583235984278742603970474190403890130765749990367903252262002072587910\
429054774362068368774173941070297008442489294012009854536258830415862\
001026233601932344280848478311160293863396081520870580210115748436524\
657593623927560968681489580983408355730739817090564200452344480956466\
381973804084046550012066308187061061100110433589729129116029838272092\
901063648710371584105178456534823033698557959547864668022626855435088\
024359991640953946734473401247145052161022214741899909693164691548573\
821785788946845900456932321418241684343132825893391173058763344836847\
561532940469059613092910143220708525884711120599623251659635879284306\
638801656363654771702535511935418881751805284684639099720239245439664\
571842387562222732097503344638539281322245536316693520241269544702385\
049026321864386637211322748517569828937467849864554760880814644586902\
817967247583917815946609090107550203264295298049898171083475299519485\
282963287445433963699470262712938411098771816976399495400566249571554\
094495292701957093458478414339743747576653696376752337387560862213437\
171824313862829623700800362750977008073325563635225466282360187411791\
004460727184883484132079024845042715007472443596920902083444577226102\
532571137758684844047433693020711502451132357889672168805441775716452\
471223267485604392625754951730382003113622464055081487391284375971238\
853510627596734712602568020285819183336971657562681282095948698659234\
622044625115938725879037169105695234784581029833751973597798676995302\
820884283310795836154247808946969995709972175704217930343337176372368\
862218152343059149076729388531979947396606020581038592064065753946089\
640553006735037214127820206440877419296330789981018521912638631997758\
154425722605472882333085781306809018684379163283706047649566390105938\
809942463192339285589573741721981180866761153351707263614777114324027\
136937248695379341939585067028628395598691094985690489914777669408583\
746705372076602176542601034547167613728331521534397507629206646312256\
534389673241695353105144035296082219501881690212574125509794054226513\
021405438270518614391742936205107159583300586830731485581286071874470\
727979146719804857783111177975437027458797939861069790512476711658674\
604230600339893922108479411334570557026813885541027537801880370343641\
023092718791324902103002359243661089565315113361994869576663697256249\
871813213413860690428249292925393115314038327834441363912113929007244\
105471054120698871274356091169876130969421130575239706338621628737248\
013101040294797899746928168358267493688407646225609161528591367536543\
750216752349842458665061074845656012652829943203210569645609847648814\
464710028370158307713272436594791806761106756447396480204361732530948\
047135168932828677349682361477634216624699993497496226478447072051536\
537255860545682337598542734838920307113252752500355434131067856495860\
013015939155932613207379195719908219623615714946387317825854512782265\
937569392814353157780475720686522817497914676681978626797926015043212\
826447031437776044826145179616020689954105388440566444703570607428452\
666825975085482722275544761731568680350317329391266355823582648567151\
947184773262263887240258693650257727510270752946231093646966589567787\
620541476932789987792695230980505405781968028822750078627313420324636\
601974910918848756407395140464009616507265266662863541465532812264494\
701633405156590660566452973010384370953314634322907040294450198353359\
957924325079183731192016465188487102068495632766765696940620843045103\
075957849189229063712905056032682667355175647119287597317113053888818\
341747269372365744795936558893311837335313287268687137649853296271832\
132369232948513470597966489726144074597206798929415298656496523421111\
438648338467916198955418864697867358689690541049939526892432203616666\
140157354244656146942523547307257405470211487674868073790307956335298\
035604188659325178691582979462715732209779303725246839056014094195154\
353820392910656204599835271073979873482650919077963655893924294796451\
071058930326741588268399079872254763237331178544518654879897999507167\
887498691051777847315585246832306484530047575270468824468839052404478\
471209601574499599308373476806751619934920860932630254791766257400546\
678194740441580832758218048544328980079529926710475069635876888842466\
467601583225867324238379637406226419707584550480244266279922404975917\
076093198953314433166768787654670557582769176583516340512714290053869\
488503951481971926825225950809407051148355971332272041694340467202263\
110935023726355678876173054870475696464256078760528321123516989048437\
905956100976188680575762923547321486475620783046279082273767387016824\
192792115286420878195296354046581539918274861338294922615905787217630\
753697407328812404074746964527035054665330473788617312281599693667903\
884726439880556302179216802454355012570038449126286996206666650775493\
528788476341408273837500438601870416699570809752085526061727790246214\
345643727730520403638924836303813927425447168031067163854295638774643\
166925696428378811144048893909874892635249403446686352691414736194313\
298767484562415849033332860270431449712286909235097808003929552365629\
010360548150077790573248056575513757799999890275575803774798799936015\
705905616634068871497563319841541352544107825662325607124684540278874\
608498624966561241559324542726007033114316454480672240712785896185764\
018459995360582270280586015978104402627028899003008502473747055638994\
967693615667231861323852556312680406367619704217960527830076328909665\
965806712800730336437160882833491675135268112563043378424238104782680\
959602102200424228996956152636857516180424517857400628028239135084923\
094773283114860671676978258922786514794732997721390398253472889571181\
542100313183931206138889694321740603908008622135736073752391733441636\
975148234408515167723600503139787211196698575465893988829247150988295\
132937089264063096302850653741709786986733436740774656976239880063657\
116155268958086159207748442275467563439789929514686396554465496658320\
223447220380884994806499212763873883811980450535445134692803972297225\
867200805366193198427695091115005764789732413669084712930690653442040\
106813786879863642703849455004180398239402073854230429039162641031954\
629435099190465441189701444312997824242458302224265488820857153390295\
433793663904480181503821987893778163121705707885184807286156520157629\
597511728693723440564167397261196843175017576158234990810817702896131\
719777996015606434124732743140927899396903532009620709667134228528325\
848706155364762181691764906498404995473573942979224307302520686325900\
288588511145953186978555460750414834235036978817588590166303626158325\
467769294871096811226986831480934663697186308993101874698672583904437\
163465158962552331778051757595797546950242290952793645521079004895039\
692767591940245446458333450596276630537891924213895070280398426097844\
530715344299379556436113658378942976207843994805006705871918214642436\
109945838548091417431928423665728188757851328090987241230795008197684\
315848649413968970776608596456806202072136369956191814042287222372420\
376209481097924531222327898301388536719301209812529374055978383161560\
402366674953377258306488393460543898212575858060374138609143943928859\
421499452693460735272584637554217829456324966124714620484172913424446\
250636641856678652492289914229876278180893702329869197654678473185792\
094874734672934868913884518473192107135666898214464737134834616023649\
053147415067806966481952994992502849916799522073929134809911363179677\
895671189148802338738965744455969389857438105112202482394405648155050\
107148182005207110004872831031995654451276551356170911494177294990239\
706406481375465466239414677940243242307424235254719725545446624971669\
702152385191708483627545184792059676994807387702668551969466174546191\
070089976167204039385542807339087642680041473305403563782932907930025\
137631116987099138156108731309442818766102387852144495815142081633981\
632881697289008544444602806582589282128339148425329485634849848220805\
882301325917949871098113905536521369117102228224267823573270306372102\
733761111537455389558353499292211244045077468444864626142113431527586\
522286466400715414584503504772063203681892773106418220004132714081774\
597491999689729300930217473244191652387960550998436458561695613745236\
001166814296581318010803425510340274430917394158798175053338323409296\
895304078316728847185492126230467648404918731759558489275204921648189\
641334613191196227133110671760170019469237970548463261174795407272273\
522594027490266679150920541151365410195788704615740727927544780544422\
598110239988012126879177000540770749825882570260436809736803340431649\
136968190510191903550704362810196734029394585868150873111624960230230\
557742069350224866922860141599641459998468635023793968673951162897119\
728086035656539953320600711628909574730519685523709373470327540705653\
335220915475511410416276072511187233012726872585473193916894040338571\
374438826193136849996054292140905498913040046174642438233669539176310\
583789607407253512180368844437606025278249024331609799279741279611616\
861322584297518411616294781785530343484052036928017813197714542874623\
893104213468783249037341094505389577141052425828443310012958430792311\
727117988346582534694572112528868607300926008059143735064550160993534\
371893959294190897252785800898998220518312815414328282874244854542483\
084144884284661147300876442953535032740155789184698983999831384346153\
983006391197340820087681150346256250121310000144506507275816653211852\
630981975984817089090736179427993067512616781166472204275999534793553\
617322021833089272400054973894297458318063353685017787841264474553106\
360829049698395091798134340765126619660886558810014489484062709914663\
708741730650944920828694430958398777612704295668727426847767255490582\
442679545627467864278473335035173682763601472415196578002079707749577\
314107135213271993728277051735738264251975836466432512732611786689972\
608699337829948196681354684107480481385484849536484464106863440975075\
994217657465056219979904595946381966476849760448223076261701459070061\
687625054331070175625148912661262855682533836542470290189307124949454\
672111611301805004282852900469603204454324036160696770568960944006915\
594827374701825793755790511037718231065384570551424914193952437022019\
147130808230140601516999108348126846206887388610494786068336045545230\
386547383991447354800219696499145798056154296637585126096623520286444\
288305461145769481278589644578052606086180987165823906712158053404792\
980245030450164180495915810341531071371713245374578291912729968835571\
659825921274987410512270834924930038942448094826206189084393728747672\
357486250170830682722765817202938882549637223733854649840690650685232\
211002887389219217763704500338914117582617774854375481599185641152046\
183882661395114967337515949838169059628528759746112017143381482333240\
207636582516552896998276786656377571917952133344673723723199179946376\
062254968796003889455221680129540086287321979565069006140531343219593\
747069127462641245536369725942802473102446619255641348424461524297528\
641759974893850890344358331952587334415026185630433554813105770680276\
206280811154949857037528958921963356897630116085109662629658178710778\
798507677725507889134611505315019012251749685690615365792458854857564\
533772662584359952011155264798453844727367592264801349010155252265810\
515246872918204705203793356728720160385276922933864379463998271968011\
571842050057502044481500963066684456034610372353292476835007171599185\
633205112254564334103161056277370091676704684362484674751703624041192\
483451798952663197567989367387817982243873922712260253289081890271484\
747615351738812175971046116046683715704512701857342532265087086607996\
935283737670167056570125886297302351164891412546399612213734288573556\
707802998705475256939453877325826737570250328135497596341563973604069\
510058749824467593715612892797143945980953495801551897876585896910826\
657340220056000137661513683486183600171373811125423027860468400737050\
207216308417605601896328260029394054079292835908268096879154275973758\
803537767265303505542897864749285971624839089144357359776006475483809\
144785869118854493414954429886053110057911071312486249141267331932731\
443170671560086590341048521718826157724599080397854324398250330127048\
599828584475615760524773238222102476324281852003060478889467087936064\
942127015543352629999555455572774241802799902310803374356753670810717\
627142023717059360295954738858332133152053518410378971332898862617963\
385643221635046420724460061022318008822037969715733460287810128018162\
609928288493671713129317148472599626406209968454082954389237826444459\
758905973724812897657188701627543464370788843117544465505781860719350\
587987395303959379133404503898926022219829986363314693902502804136730\
055576160428616527247857010585845882973679162782760983001119225850793\
470860387219780160062333082975943454952693122775459243261504221260853\
490483200000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000000000000000

Larger values work fine, but exceed the maximum answer size allowed here.

\$\endgroup\$
1
  • \$\begingroup\$ I followed the advice in the question not to worry about outputs exceeding the language's integer limit. ;-) \$\endgroup\$ Commented Oct 28, 2021 at 16:22
5
\$\begingroup\$

tinylisp, 51 bytes

(load library
(d H(q((N)(i N(*(pow N N)(H(dec N)))1

Try it online!

Ungolfed

(load library)            ; for *, pow, and dec

(def hyper                ; name something
  (lambda (n)             ; a lambda function that takes one parameter n
    (if n                 ; if n...   
      (*                  ; ...is non-zero, multiply...
        (pow n n)         ; ...n raised to itself...
        (hyper (dec n)))  ; by the hyperfactorial of n-1
      1)))                ; otherwise if n is zero, return 1
\$\endgroup\$
1
  • 1
    \$\begingroup\$ 50 bytes non-recursive solution \$\endgroup\$
    – Giuseppe
    Commented Feb 3, 2022 at 13:22
4
\$\begingroup\$

Husk, 5 bytes

Πm´^ḣ

Try it online!

Π       # product of
 m      # mapping across all values of
     ḣ  # 1..input
  ´^    # x to the power of x
\$\endgroup\$
4
\$\begingroup\$

R, 20 bytes

prod((x=1:scan())^x)

Try it online!

\$\endgroup\$
4
\$\begingroup\$

Haskell, 20 bytes

h 0=1
h n=n^n*h(n-1)

Try it online!

\$\endgroup\$
4
\$\begingroup\$

Wren, 43 bytes

var F=Fn.new{|n|n<1?1:n.pow(n)*F.call(n-1)}

Try it online!

Alternate:

Wren, 44 bytes

Fn.new{|n|(1..n).reduce(1){|a,b|a*b.pow(b)}}

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ wow reminds me a lot of rust \$\endgroup\$
    – don bright
    Commented Oct 5, 2021 at 4:33
4
\$\begingroup\$

jq, 42 bytes

[range(.+1)]|reduce.[]as$i(1;.*pow($i;$i))

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ You can simplify the [range]|reduce.[] to reduce(range(.+1))as$i to save 4 bytes] \$\endgroup\$
    – Sara J
    Commented Oct 6, 2021 at 18:27
4
\$\begingroup\$

Java (JDK), 51 bytes

n->{var r=1;for(;n>0;)r*=Math.pow(n,n--);return r;}

Try it online!

\$\endgroup\$
4
\$\begingroup\$

Raku, 17 bytes

{[*] [\R*] 1..$_}

Try it online!

  • 1 .. $_ is the sequence of numbers from 1 to the input argument.
  • [\R*] is the "triangular reduction" (scan) of those numbers with the Reversed (and thus right-associative) multiplication operator, producing this list: 𝑛, 𝑛 × (𝑛-1), 𝑛 × (𝑛-1) × (𝑛-2), ..., 𝑛 × (𝑛-1) × (𝑛-2) × ... × 1.
  • [*] is the product of those numbers, which contains 𝑛 factors of 𝑛, 𝑛-1 factors of 𝑛-1, etc, as required.

If the input argument is zero, 1 .. $_ is an empty range, [\R*] applied to that range produces an empty list, and [*] applied to that list returns the multiplicative identity element 1.

\$\endgroup\$
4
\$\begingroup\$

TI-Basic, 19 17 14 bytes

prod(seq(I^I,I,1,Ans+not(Ans

sadly 0^0 or an empty list errors, so 0 has to be turned into 1

\$\endgroup\$
4
\$\begingroup\$

Factor + math.factorials, 15 bytes

hyper-factorial

Try it online!

Built-in.

Factor + math.unicode, 33 27 bytes

[ [1,b] [ dup ^n ] map Π ]

Try it online!

This could have been 26 bytes, but ^ returns NaN for 0^0. Factor is the only language I know of that doesn't just return 1 for that. So I had to use ^n instead, which is a helper word used to implement ^ that hasn't been 'fixed' yet.

  • [1,b] A range from 1 to whatever is on top of the data stack, inclusive.
  • dup ^n Raise an integer to itself.
  • [ ... ] map Apply a quotation to each element of a sequence, collecting the results in a new sequence of the same length.
  • Π Product of a sequence.
\$\endgroup\$
1
  • 1
    \$\begingroup\$ You can add Mathematica to that list :) \$\endgroup\$
    – att
    Commented Oct 5, 2021 at 19:59
4
\$\begingroup\$

BLC, 8 bytes (61 bit)

0000010101110000001011010011100000010111101100111010001100010

Works for Church encoded numerals with 1=i. The code is derived from the common fac function. Degolfed to bruijn:

fac [[1 [[id (1 [[2 1 (1 0)]])]] [1] [0]]]
    id 0

hyperfac [[1 [[exp (1 [[2 1 (1 0)]])]] [1] [0]]]
    exp (0 0)
\$\endgroup\$
1
  • 1
    \$\begingroup\$ Welcome to Code Golf, and nice answer! \$\endgroup\$
    – rydwolf
    Commented Oct 14, 2023 at 23:05
3
\$\begingroup\$

C (gcc), 28 bytes

H(n){n=n?pow(n,n)*H(--n):1;}

Try it online!

\$\endgroup\$
3
\$\begingroup\$

Vyxal, 4 bytes

ɾ:eΠ

Try it Online!

Obligatory answer

ɾ              # Range
:              # Dup
e             # Power
Π            # Product
\$\endgroup\$
3
\$\begingroup\$

Zsh, 33 bytes

for ((a=1;n++<$1;a*=n**n)):
<<<$a

Attempt This Online!

\$\endgroup\$
3
\$\begingroup\$

Scala, 40 38 bytes (supporting Big Integers)

1.to(_).map(x=>BigInt(x)pow x).product

Provides exact results up to crazy large numbers with several billions of digits, namely up to Hyperfactorial(2^31-1).

Saved 2 bytes thanks to @user.

Try it online!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Nice, you can do BigInt(x)pow x to save a couple bytes \$\endgroup\$
    – user
    Commented Dec 24, 2021 at 21:34
3
\$\begingroup\$

Brachylog, 7 bytes

⟦gjz^ᵐ×

Try it online!

Explanation

⟦            Range: [0, …, Input]
 g           Nest in a list: [[0, …, Input]]
  j          Juxtapose: [[0, …, Input], [0, …, Input]]
   z         Zip: [[0, 0], …, [Input, Input]]
    ^ᵐ       Map power: [1, …, Input^Input]
      ×      Multiply: 1 × … × Input^Input
\$\endgroup\$
3
\$\begingroup\$

Thunno 2, 4 bytes

RD*p

Explanation

RD*p  # Implicit input            6
R     # Push the one-range        [1, 2, 3, 4, 5, 6]
  *   # Each to the power of...
 D    # ...itself                 [1, 4, 27, 256, 3125, 46656]
   p  # Product of the list       4031078400000
      # Implicit output
\$\endgroup\$
3
\$\begingroup\$

Uiua, 7 bytes

/×ⁿ.+1⇡

Try it!

/×ⁿ.+1⇡
    +1⇡  # 1..n
   .     # duplicate
  ⁿ      # power
/×       # product
\$\endgroup\$
3
\$\begingroup\$

K (ngn/k), 6 bytes

*/&!1+

Try it online!

  • !1+ generate 0..x (e.g., with an input of 4, generate 0 1 2 3 4)
  • & take n copies of each n, e.g. zero copies of 0, one copy of 1, two copies of 2, etc.)
  • */ calculate (and implicitly return) the product
\$\endgroup\$
5
  • \$\begingroup\$ @coltim : I think zero hyper-factorial is a 1, not "zero copies of 0" \$\endgroup\$ Commented Jul 6 at 2:31
  • 1
    \$\begingroup\$ Ah, that is true, but */ (a multiply-reduce) of an empty list (e.g. zero copies of 0) is 1 (from the identity element of multiplication). \$\endgroup\$
    – coltim
    Commented Jul 8 at 23:38
  • \$\begingroup\$ so how would, say, 5 HF work ? */&!5+ ? \$\endgroup\$ Commented Jul 9 at 22:18
  • \$\begingroup\$ Ah, the provided snippet is "tacit"; it doesn't take an explicit argument, but can be assigned to a variable and then called as a function later. On the "Try it online!" link you can enter f 5 and see the result printed in the right panel. So the way to call this with an input of 5 is either f:*/&!1+;f 5, or */&!1+5. Working through each operation results in 0 1 2 3 4 5 => 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 => 86400000 \$\endgroup\$
    – coltim
    Commented Jul 11 at 11:58
  • \$\begingroup\$ ahhhhhhhhh gotcha. I have more faith in hearing your explanation than that Try it Online site, which is primarily financed by Dyalog APL (as stated on the site itself) instead of a neutral third party. But side note - did you know 5 hyperfactorial just happens to be the # of milliseconds in a day, which can also be cutely expressed as (1+2)^3 * (4*5)^5 ? \$\endgroup\$ Commented Jul 11 at 23:36
3
\$\begingroup\$

sed 4.2.2 -r, 291 287 276 260 255 251 248 240 233 228 226 220 219 212 209 208 207 196 193 191 184 181 177 175 173 170 169 165 164 163 bytes

h;G;G
:;s/.//;x;s/\s.*//
:a;s/#*/& &/;T;x;s/^##/#/;x;ta
x;s/#.#//;H;g;s/ //g;/\n##+\n/t;T
s/(#+)\n#.#(#*)/\2\n\2\n\2	\1/;h;t
s/.#?\n+/#/;h;T;s/.*	#//;x;s/	#*$//;ta

Try it online! (cases 0-4; slow)
Try it online! (cases 0-5; fast, +1 byte)
Try it online! (cases 0-7; calculate the powers but don't multiply them together)

takes input and output as unary #s. TIO links include conversion to/from decimal in header/footer.

after two months and 100 bytes of golfing, I think it's high time to actually write out an explanation. normally, I add the explanation in comments next to the code, but I think explaining the data format first will work better with this one. the PATTERN and HOLD spaces are switched around a lot, but let's call this the initial PATTERN space:

add
mult
pow	prev

each 'variable' is a unary number of #s which keeps track of how many more times we need to preform each operation. the first one used is add, where the a loop adds the HOLD space (which is currently pow) to itself and decrements add. once add is 0 (ie HOLD now equals add * pow), mult gets decremented by one and add is set to HOLD. once mult is 1 (ie HOLD now equals pow ^ pow), pow is decremented, add and mult are set to pow, and prev gets set to HOLD\tprev (where \t is a tab). once pow is 0, we have calculated n^n for every n, starting at the input and going all the way down to 0, with the results separated by tabs. finally, the last time we loop through is to multiply these results together, which we do by first removing all newlines to let it pass through the first checks, and loading the final result into the HOLD space while deleting it from the PATTERN space until there is only one result left.

description of code by line:

1: sets the format up like how I described as 'initial PATTERN space' where the HOLD space is the input and the PATTERN space is the input repeated three times
2: a 'prefix' which takes care of an off-by-one error and discards junk that accumulates in the HOLD space
3: the `add` loop, which ends with the HOLD space equaling HOLD space * first line of PATTERN space
4: the `mult` loop, which ends with the HOLD equaling HOLD space ^ second line of PATTERN space
5: the `pow` loop, which saves the result of the `mult` loop after a tab and restarts everything with a decremented input
6: the `final` loop, which removes all the newlines to bypass the `mult` and `pow` loops, and multiplies the first result to the last result until there is only one result
\$\endgroup\$
2
\$\begingroup\$

05AB1E, 4 bytes

LDmP

Try it online or verify all test cases.

Explanation:

L     # Push a list in the range [1, (implicit) input-integer]
      # (note: input 0 will create the list [1,0])
 D    # Duplicate this list
  m   # Take the exponent of the two lists at the same positions
   P  # Take the product of this list
      # (after which the result is output implicitly)
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.