Logo

Programming-Idioms

History of Idiom 31 > diff from v78 to v79

Edit summary for version 79 by programming-idioms.org:
[JS] Argument name i

Version 78

2022-05-23, 13:20:25

Version 79

2022-05-23, 13:20:55

Idiom #31 Recursive factorial (simple)

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

Idiom #31 Recursive factorial (simple)

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

Variables
f,i
Variables
f,i
Code
function f(n) {
   return n<2 ? 1 : n * f(n-1);
}
Code
function f(i) {
   return i<2 ? 1 : i * f(i-1);
}