<div dir="ltr"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.727272033691406px">(I noticed that the code ran under Racket v5.3.4. but under<br>
</span><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.727272033691406px">Racket v5.2.1. none of the code ran - it showed<br></span><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.727272033691406px">for: bad sequence binding clause at: #:break?)</span></blockquote>
<div><br></div><div>The #:break clause isn't available in the for form of v5.2.1:</div><div><br></div><div><a href="http://download.racket-lang.org/docs/5.2.1/html/reference/for.html?q=for#(form._((lib._racket/private/base..rkt)._for))">http://download.racket-lang.org/docs/5.2.1/html/reference/for.html?q=for#(form._((lib._racket/private/base..rkt)._for))</a></div>
<div><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.727272033691406px"><br></span></div><div><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.727272033691406px">When first learning Racket coming from an imperative programming background it's a good idea to avoid set! for a while to get a feel for the functional aspects of the idiom.</span></div>
<div><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.727272033691406px"><br></span></div><div><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.727272033691406px">Here's a rewrite of the first version of your program with the set!s removed and using straight recursion</span></div>
<div><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.727272033691406px">instead of iteration:</span></div><div><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.727272033691406px"><br>
</span></div><div><div><font color="#000000" face="courier new, monospace">#lang racket</font></div><div><font color="#000000" face="courier new, monospace"><br></font></div><div><font color="#000000" face="courier new, monospace">(define (divides? a b)</font></div>
<div><font color="#000000" face="courier new, monospace"> (= (remainder a b) 0))</font></div><div><font color="#000000" face="courier new, monospace"><br></font></div><div><font color="#000000" face="courier new, monospace">(define (L i maxp number)</font></div>
<div><font color="#000000" face="courier new, monospace"> (cond [(= number 1) maxp]</font></div><div><font color="#000000" face="courier new, monospace"> [(divides? number i) (L (+ i 2) i (/ number i))]</font></div>
<div><font color="#000000" face="courier new, monospace"> [else (L (+ i 2) maxp number)]))</font></div><div><font color="#000000" face="courier new, monospace"><br></font></div><div><font color="#000000" face="courier new, monospace">(L 3 0 165)</font></div>
</div><div class="gmail_extra"><br>[This also works as #lang scheme]</div><div class="gmail_extra"><br></div><div class="gmail_extra">You might want to try a Racket-based text to get immersed in the functional / recursive idiom. </div>
<div class="gmail_extra">HTDP is the usual blanket recommendation (free online), but now there are other options like Realm of Racket. Scheme-based books also have a lot to offer.</div><div class="gmail_extra"><br></div>
<div class="gmail_extra">
<a href="http://rosettacode.org">rosettacode.org</a> has plenty of short Racket and Scheme examples to peruse and compare with examples in familiar languages.</div><div class="gmail_extra"><br></div><div class="gmail_extra">
Dan</div><div class="gmail_extra"><div dir="ltr"></div>
</div></div>