Logo

Programming-Idioms

History of Idiom 31 > diff from v38 to v39

Edit summary for version 39 by Dodopod:
New Scheme implementation by user [Dodopod]

Version 38

2017-03-19, 20:58:32

Version 39

2017-06-14, 15:08:13

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
(define (f i)
  (if (> i 1)
      (* (f (- i 1)) i)
      1))