mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 21:59:17 +02:00
7 lines
200 B
Scheme
7 lines
200 B
Scheme
(define-library (pingala factorial)
|
|
(export factorial)
|
|
(import (scheme base))
|
|
(begin
|
|
(define (factorial n)
|
|
(let lp ((n n) (res 1))
|
|
(if (<= n 1) res (lp (- n 1) (* res n)))))))
|