Created
January 27, 2013 09:51
-
-
Save lyuehh/4647609 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (factor n) | |
(if (= n 1) | |
1 | |
(* n (factor (- n 1))))) | |
(define (factor2 n) | |
(factor-iter 1 1 n)) | |
(define (factor-iter product counter max-count) | |
(if (> counter max-count) | |
product | |
(factor-iter (* product counter) (+ counter 1) max-count))) | |
(define (factor2 n) | |
(define (iter product counter) | |
(if (> counter n) | |
product | |
(iter (* product counter) (+ counter 1)))) | |
(iter 1 1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment