<html><head/><body><html><head></head><body>For one thing, the question you are asking in the code,<br>
        (> i 4) ;; i.e., i > 4<br>
is not the same question you ask in your equations,<br>
        n < 4<br>
so, for starters, it would seem you need the two questions to be in agreement.<br>
<br>
Best,<br>
jmj <br>
-- <br>
Sent from my Android phone with K-9 Mail.<br><br><div class="gmail_quote">Robert Hume <rhume55@gmail.com> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
I'm really stuck trying to figure this out. Any pointers are useful! Here's the problem:<br /><br />f(n) = n if n<4 <br />and <br />f(n) = f(n - 1) + 2f(n - 2) + 3f(n - 3) + 4f(n - 4) if n>= 4<br /><br />Here's my solution so far -- any one know what I'm doing wrong?<br />
<br />(define (f n)<br /><br /> (define (f-iter result i)<br /> (if (> i 4)<br /> result<br /> (f-iter (+ result (* i (- n i))) (+ i 1))<br /> )<br /> )<br /><br /> (if (< n 4)<br /> n<br /> (f-iter 0 1)<br />
)<br /><br />)<br /><br />(f 4) ;; should produce 10, produces 10<br />(f 5) ;; should produce 26, produces 20<br />(f 6) ;; should produce 63, produces 30<br />
<p style="margin-top: 2.5em; margin-bottom: 1em; border-bottom: 1px solid #000"></p><pre style="white-space: pre-wrap; word-wrap:break-word; font-family: monospace; margin-top: 0px">____________________<br />Racket Users list:<br /><a href="http://lists.racket-lang.org/users">http://lists.racket-lang.org/users</a><br /></pre></blockquote></div></body></html></body></html>