sicp-ex-3.54



<< Previous exercise (3.53) | Index | Next exercise (3.55) >>


 (define factorials (cons-stream 1 (mul-streams (add-streams ones integers) factorials))) 

leafac

I believe the above is wrong, because `integers' start at 1 and we want the factorial of `n + 1'. Also, it's missing the `mul-streams'. Here's my solution:

 (define (mul-streams s1 s2) 
   (stream-map * s1 s2)) 
  
 (define factorials (cons-stream 1 (mul-streams integers factorials))) 

ict

To make the stream have the nth element be n+1!, shoudn't the function be:

  
 (define factorials  
   (cons-stream 1  
                (mul-streams factorials (stream-cdr integers)))) 

I agree with you. I also have the same definition.