Programming-Idioms

History of Idiom 31 > diff from v25 to v26

Edit summary for version 26 :
[Ada] Corrected parameter name from N to I

Version 25

2016-02-17, 16:59:13

Version 26

2016-02-17, 17:00: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
function F (N : Natural) return Natural is (if N < 2 then 1 else N * F (N - 1));
Code
function F (I : Natural) return Natural is (if I < 2 then 1 else I * F (I - 1));