Logo

Programming-Idioms

History of Idiom 31 > diff from v70 to v71

Edit summary for version 71 by Patrick R:
New Smalltalk implementation by user [Patrick R]

Version 70

2021-08-19, 04:56:30

Version 71

2021-09-24, 09:20:07

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)

Variables
f,i
Variables
f,i
Code
f := [:i | i = 0 ifTrue: [1] ifFalse: [i * (f value: i - 1)]].