Skip to content

Instantly share code, notes, and snippets.

@PuercoPop
Created January 4, 2013 21:53
Show Gist options
  • Save PuercoPop/4457363 to your computer and use it in GitHub Desktop.
Save PuercoPop/4457363 to your computer and use it in GitHub Desktop.
;; Recursive Process
(define (factorial n)
(if (= n 1)
1
(* n (factorial (- n 1)))))
;; Iterative Process
(define (factorial n)
(fact-iter 1 1 n))
(define (fact-iter product counter max-count)
(if (> counter max-count)
product
(fact-iter (* counter product)
(+ counter 1)
max-count)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment