Programming-Idioms

History of Idiom 31 > diff from v2 to v3

Edit summary for version 3 :

Version 2

2015-07-31, 19:46:17

Version 3

2015-08-01, 17:26:03

Idiom #31 Recursive factorial (simple)

Create recursive function f which returns the factorial of non-negative integer i, calculated from f(i-1)

Idiom #31 Recursive factorial (simple)

Create recursive function f which returns the factorial of non-negative integer i, calculated from f(i-1)

Code
function f(n) {
   if (n<2) return 1;
   return n * f(n-1);
}