Logo

Programming-Idioms

History of Idiom 31 > diff from v53 to v54

Edit summary for version 54 by miguel:
New Kotlin implementation by user [miguel]

Version 53

2019-09-26, 21:54:17

Version 54

2019-09-26, 21:54:41

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
fun f(i: Int) = if (i == 0) 1 else i * f(i - 1)