Structure and Interpretation of Computer Programs section 1.2.1 Linear Recursion and Iteration:
Compare the two processes... each requires a number of steps proportional to n to compute n!
The two processes are specified by
(define (factorial n)
(if (= n 1)
1
(* n (factorial (- n 1)))))
;; This is the linear recursive process
(define (factorial n)
(define (iter product counter)
(if (> counter n)
product
(iter (* counter product)
(+ counter 1))))
(iter 1 1))
;; This is the linear iterative process
My question is: how do both processes require a number of steps proportional to n to compute n! ?