Code Review
Compare your solutions
#| BEGIN (Write your solution here) |#
(define (product term a next b)
(if (> a b)
1
(* (term a)
(product term (next a) next b))))
(define (factorial n)
(product identity 1 inc n))
#| END |#
#| BEGIN (Write your solution here) |#
(define (product term a next b)
(define (iter a result)
(if (> a b)
result
(iter (next a) (* (term a) result))))
(iter a 1))
(define (factorial n)
(product identity 1 inc n))
#| END |#
#| BEGIN (Write your solution here) |#
(define (product term a next b)
(if (> a b)
1
(* (term a)
(product term (next a) next b))))
(define (factorial n)
(product identity 1 inc n))
#| END |#
#| BEGIN (Write your solution here) |#
(define (product term a next b)
(define (iter a result)
(if (> a b)
result
(iter (next a) (* (term a) result))))
(iter a 1))
(define (factorial n)
(product identity 1 inc n))
#| END |#