Skip to main content
1 of 4
ricdesi
  • 519
  • 2
  • 13

JavaScript, 34ch

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