Programming-Idioms

History of Idiom 31 > diff from v12 to v13

Edit summary for version 13 :

Version 12

2015-09-04, 15:43:53

Version 13

2015-09-04, 15:45:00

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
factorial n = if n > 1 then n * factorial (n-1) else 1
Code
factorial i = if i > 1 then factorial (i-1) * i else 1