mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-18 21:29:19 +02:00
14 lines
187 B
Scheme
14 lines
187 B
Scheme
|
|
(define (fact-helper x res)
|
|
(if (= x 0)
|
|
res
|
|
(fact-helper (- x 1) (* res x))))
|
|
|
|
(define (fact x)
|
|
(fact-helper x 1))
|
|
|
|
(display "(fact 3) => ")
|
|
(write (fact 3))
|
|
(newline)
|
|
|
|
|