<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.7600.16671"></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=374210011-05112010><FONT color=#0000ff
size=2 face=Arial>Actually there is one more way. We only have to check numbers
1 up to the integer-sqrt of n. For each check whose remainder is 0, we
immediately have two divisors, the checking number and the quotient (except
when these two are equal, giving one divisor only -this happens only when n
is a square-))</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=374210011-05112010><FONT color=#0000ff
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=374210011-05112010><FONT color=#0000ff
size=2 face=Arial>Jos</FONT></SPAN></DIV>
<DIV dir=ltr align=left>
<HR tabIndex=-1>
</DIV>
<DIV dir=ltr align=left><FONT size=2 face=Tahoma><B>From:</B>
users-bounces@racket-lang.org [mailto:users-bounces@racket-lang.org] <B>On
Behalf Of </B>Todd O'Bryan<BR><B>Sent:</B> 05 November 2010 10:31<BR><B>To:</B>
lukejordan@gmail.com<BR><B>Cc:</B> users@racket-lang.org<BR><B>Subject:</B> Re:
[racket] Generative recursion<BR></FONT><BR></DIV>
<BLOCKQUOTE
style="BORDER-LEFT: #0000ff 2px solid; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px"
dir=ltr>
<DIV></DIV>There are really two ways of doing this problem. The way I'd
probably use is to make a list of all the *possible* divisors and then use the
filter function to pull out the actual divisors.
<DIV><BR></DIV>
<DIV>The way you're probably thinking of requires a helper function for the
recursion, because you need to keep track of where you are in building up the
list. Back in the section on natural numbers, there are exercises to create
lists of numbers of varying types, for example:</DIV>
<DIV><BR></DIV>
<DIV>; list-from-a-to-b: number number -> list-of-number</DIV>
<DIV><BR></DIV>
<DIV>(check-expect (list-from-a-to-b 3 7) (list 3 4 5 6 7))</DIV>
<DIV><BR></DIV>
<DIV>If you can figure out how to write this function, then you just need to
include a conditional to decide whether to add the next number into the list
you're creating or not.</DIV>
<DIV><BR></DIV>
<DIV>Todd</DIV>
<DIV><BR>
<DIV class=gmail_quote>On Wed, Nov 3, 2010 at 7:18 PM, Luke Jordan <SPAN
dir=ltr><<A
href="mailto:luke.jordan@gmail.com">luke.jordan@gmail.com</A>></SPAN>
wrote:<BR>
<BLOCKQUOTE
style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex"
class=gmail_quote>I found implementing this trickier than grasping the
solution as well. Stick with it. I don't see that you need any
functions related prime numbers. Perhaps if input is prime that is a
trivial case, but try to focus on what the output is: A list of numbers that
can evenly divide the input. Those numbers are the numbers from 1 to
input. To think about how to get that list, try solving it by hand.
If input is 3, how do you go about it? Does 3 divide 3 with no
remainder? Yes, we know that numbers divide themselves with no
remainder. How about 2? 1? Try it over with larger numbers, like
6 and 10. What process are you using to determine whether the numbers
<= input and > 1 divide input with no remainder, and what happens to
them if do? What happens if they do not? When does evaluation
cease? When it comes to a termination statement, don't forget that
list and append are different.
<DIV><BR></DIV>
<DIV>Trying not to say too much, but hope I'm still saying something
useful.</DIV>
<DIV><BR></DIV>
<DIV>- Luke<BR>
<DIV><BR>
<DIV class=gmail_quote>
<DIV>
<DIV></DIV>
<DIV class=h5>On Wed, Nov 3, 2010 at 17:43, Ken Hegeland <SPAN
dir=ltr><<A href="mailto:hegek87@yahoo.com"
target=_blank>hegek87@yahoo.com</A>></SPAN> wrote:<BR></DIV></DIV>
<BLOCKQUOTE
style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex"
class=gmail_quote>
<DIV>
<DIV></DIV>
<DIV class=h5>
<TABLE border=0 cellSpacing=0 cellPadding=0>
<TBODY>
<TR>
<TD vAlign=top>I am trying to do the problem 26.1.1 in the book HTDP
and I just feel like the more I think about it, the more confused I
get. I found a post from 2007 with some tips from Jens Axel Søgaard,
the link is <A
href="http://objectmix.com/scheme/186349-htdp-generative-recursion.html"
target=_blank>http://objectmix.com/scheme/186349-htdp-generative-recursion.html</A>.<BR><BR>I
understand whats to be done, but Im just unsure how to accomplish
the task. I believe that trivially solvable in this case is n=1 and
n=prime. For n=1 the solution would be (list 1)<BR>for n=prime Im
thinking it should be (list 1 n), my function is similar to the one
on the link with a bit of different organization. When I read jens'
tips near the end I am getting confused.<BR>The closest I can get to
an answer is, (=(tabulate-div 20)(list 20 10 5 2 2))<BR><BR>From the
advice supplied, I was able to say that the smaller problems that
you split the program into are, one to get the largest divisor, and
one which gets the smallest divisor using the largest.<BR><BR>As far
as template I am using what is supplied in the book. Im simply
stuck, and would love something to help me out, I will continue to
run this problem through my head and see what I can come up
with.<BR><BR>Thanks in advance for any
help.<BR></TD></TR></TBODY></TABLE><BR><BR></DIV></DIV>_________________________________________________<BR> For
list-related administrative tasks:<BR> <A
href="http://lists.racket-lang.org/listinfo/users"
target=_blank>http://lists.racket-lang.org/listinfo/users</A><BR></BLOCKQUOTE></DIV><BR></DIV></DIV><BR>_________________________________________________<BR> For
list-related administrative tasks:<BR> <A
href="http://lists.racket-lang.org/listinfo/users"
target=_blank>http://lists.racket-lang.org/listinfo/users</A><BR></BLOCKQUOTE></DIV><BR></DIV></BLOCKQUOTE></BODY></HTML>