Skip to main content
5 of 8
added 130 characters in body
Shaggy
  • 43.5k
  • 4
  • 36
  • 94

#JavaScript (ES6), 33 28 23 bytes

(n,x=n)=>--x?n*f(n,x):n

Add 7 bytes if we need to allow for negative integers.

(n,x=n>0?n:-n)=>--x?n*f(n,x):n

And add 3 bytes if 0 should be output for input 0

(n,x=n>0?n:-n)=>n&&--x?n*f(n,x):n

##Try It

f=
(n,x=n)=>--x?n*f(n,x):n
o.innerText=f(i.value=3)
i.oninput=_=>o.innerText=f(+i.value)
<input id=i min=0 type=number><pre id=o>


##History ###28 bytes n=>eval(1+("*"+n).repeat(n)) ###33 bytes n=>eval(Array(n).fill(n).join*)

Shaggy
  • 43.5k
  • 4
  • 36
  • 94