Skip to content

Instantly share code, notes, and snippets.

@chelseatroy
Created October 29, 2019 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chelseatroy/258127ddc577bad6ab5f3157cdfb68cb to your computer and use it in GitHub Desktop.
Save chelseatroy/258127ddc577bad6ab5f3157cdfb68cb to your computer and use it in GitHub Desktop.
Iterative Function
(define (sum-i n)
(define (iter n sofar)
(if (= n 0)
sofar
(+ (iter (- n 1) (+ n sofar)))))
(iter n 0)
)
(sum-i 5) ; 15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment