picrin/t/tailcall.scm

7 lines
102 B
Scheme

(define (sum k acc)
(if (zero? k)
acc
(sum (- k 1) (+ k acc))))
(display (sum 1000 0))