Code Review
Compare your solutions
#| BEGIN (Write your solution here) |#
;recursive
(define (product term a next b)
(if (> a b)
1
(* (term a)
(product term (next a) next b))))
;iterative
(define (product term a next b)
(define (iter a result)
(if (> a b)
result
(iter (next a) (* (term a) result))))
(iter a 1))
;helper
(define (inc x) (+ x 1))
(define (self x) x)
;factorial
(define (factorial x)
(product self 1 inc x))
#| END |#
#| BEGIN (Write your solution here) |#
;recursive
(define (product term a next b)
(if (> a b)
1
(* (term a)
(product term (next a) next b))))
;iterative
(define (product term a next b)
(define (iter a result)
(if (> a b)
result
(iter (next a) (* (term a) result))))
(iter a 1))
;helper
(define (inc x) (+ x 1))
(define (self x) x)
;factorial
(define (factorial x)
(product self 1 inc x))
#| END |#
#| BEGIN (Write your solution here) |#
;recursive
(define (product term a next b)
(if (> a b)
1
(* (term a)
(product term (next a) next b))))
;iterative
(define (product term a next b)
(define (iter a result)
(if (> a b)
result
(iter (next a) (* (term a) result))))
(iter a 1))
;helper
(define (inc x) (+ x 1))
(define (self x) x)
;factorial
(define (factorial x)
(product self 1 inc x))
#| END |#
#| BEGIN (Write your solution here) |#
;recursive
(define (product term a next b)
(if (> a b)
1
(* (term a)
(product term (next a) next b))))
;iterative
(define (product term a next b)
(define (iter a result)
(if (> a b)
result
(iter (next a) (* (term a) result))))
(iter a 1))
;helper
(define (inc x) (+ x 1))
(define (self x) x)
;factorial
(define (factorial x)
(product self 1 inc x))
#| END |#