# 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

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

# Vyxal, 7 bytes

?ɾƛ:e;Π


Try it Online!

• This can be ɾ:eΠ for 4 bytes - input is implicitly taken if there's nothing on the stack and e vectorises (applies to each item in each list) by default Commented Dec 30, 2021 at 10:19

# Excel, 33 bytes

=LET(x,SEQUENCE(A1),PRODUCT(x^x))


# Python + mpmath, 28 bytes

from mpmath import*
hyperfac

Attempt This Online!

# Knight, 30 bytes

;=p=w 1;=qP;W<w q=p*p^=w+wTwOp


Try it online!

# Knight (v2.0-alpha), 27 bytes

;;=i^=n+0PnW=n-nT=i*i^n nOi


Try it online!

# J, 11 bytes

[:*/1^~@+i.


Attempt This Online!

[:*/1^~@+i.
[:          NB. enforce f (g x)
*/        NB. product reduce
i. NB. range 0..x-1
@    NB. then
^~     NB. raise each item to itself


# K (ngn/k), 15 bytes

+/*/'{x#x}'1+!:


Try it online!

Explanations:

+/*/'{x#x}'1+!:  Main function. Takes implicit input with :
!   Range from [0..input-1]
1+    + 1 to turn it into [1..input]
'      For each number...
{   }       Execute a function that...
x        Takes the number as implicit variable x
x#         And duplicate them x amount of times
'            For each of the lists inside...
*/             Fold and multiply them
+/               Sum


1$01.11-1< >:>:?v~:?^~l1=?n*a1. 1-^ >$:}$ Try it online Explanation Initializes product as 1 to handle the n=0 special case. Loops over x from n down to 1 and puts x copies of x on the stack. Ex: n=3 results in 3,3,3,2,2,1 Then takes the product of all numbers on the stack to get the result. # Arturo, 29 22 bytes $=>[∏map..1&'x->x^x]


Try it

# Lua, 38 bytes

a=1 for i=1,...do a=a*i^i end print(a)


Try it online!

# Uiua, 7 bytes

/×ⁿ.+1⇡


Try it!

/×ⁿ.+1⇡
+1⇡  # 1..n
.     # duplicate
ⁿ      # power
/×       # product


# Rust, 40 bytes

|n|(1u32..=n).map(|n|n.pow(n)).product()


Attempt This Online!

Staightforward functional approach. Follows the rules for type inference. As the program takes and returns a u32, only calls up to H(5) are supported. This is because {integer}::pow takes a u32, and casting would cost five bytes.

# Arn, 5 bytes

Uses the slightly older online version

O«▒¹Ù


Try it!

# Explained

Unpacked: *{^}\~

         _    Implied variable, initialized to input
~    Range 1..
*…\  fold with multiplication after mapping
{   block with key of _, initialized to current number
^  raise _ to the power of _
} end block


# Assembly (NASM, 32-bit, Linux), 85 bytes

H:mov ebx,eax
or ax,0
mov ax,1
je z
n:mov ecx,ebx
x:mul ebx
loop x
dec bx
jnz n
z:ret


Try it online!

The argument to the H function is passed in the eax register. The result is also in the eax register. The input has to be lower than 65,536.

# Cognate, 36 bytes

(Let N;For Range 1 + 1 N(* ^ Twin)1)


Attempt This Online!

# Pyt, 3 bytes

řṖΠ


Try it online!

ř            implicit input (n); push [1,2,3,...,n]
Ṗ           raise each element to the power of itself
Π          take the product of all of them; implicit print


# SageMath, 35 bytes

Without using NATIVE python module or syntax

Golfed vesrion. Run it on SageMathCell!

f=lambda n:prod(i^i for i in[1..n])