"We're still doing too much work. Why go all the way up to n? We know
that (say) 93 can't possibly divide into 99, or 57 into 59. The largest
number we need to check is the square root of n. The reason is a little
subtle, so think about it, don't just take my word.

Hint: write down the factors of, say, 60: Can you see the pattern?

2*30, 3*10, 5*6, 6*5, 10*3, 30*2
--
Steven D'Aprano"

Thanks so much Steven.  I get it all except I don't think I see the pattern.  I 
see that we're already covering those higher factors since they're divisble by 
2, 3, 5, etc.  I'm just not connecting the final dot with the square root of n. 
 It's almost there in my mind!  I just need a little more of a push!  Also I 
can write a program that tests whether the number is a factor of 2, 3, 5, 7, 
but I think you're trying to point to me that this is cumbersome and not 
necessary.  I just don't see the rest of the light quite yet.  I have been 
looking at code on the internet too, but there are lots of different ways to 
skin a cat and it seems people are taking advantage of that.  I keep hitting 
road blocks in code.  I want to understand!
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to