Skip to main content
4 of 4
fix header
user avatar
user avatar

##JavaScript, 34 bytes function f(n){return n?n*f(n-1):1}

(or)

function f(n){return n?n*f(--n):1} 

###Explanation

Function takes in a value, returns itself multiplied by
if n != 0: the same function on the number decreased by one
if n == 0: 1

The final f(0) returns first with 1, times 1, times 2, etc.

Terminator removed, may upset use strict.

ricdesi
  • 519
  • 2
  • 13