Logo

Programming-Idioms

History of Idiom 31 > diff from v76 to v77

Edit summary for version 77 by programming-idioms.org:
[JS] Function name f, argument name i

Version 76

2022-03-04, 20:37:27

Version 77

2022-05-23, 13:19:53

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
const fact = n => n === 0 ? 1 : n * fact(n-1)
Code
const f = i => i === 0 ? 1 : i * f(i-1)