elz: (ada-tubes)
elz ([personal profile] elz) wrote in [community profile] intro_to_cs 2009-11-12 01:15 pm (UTC)

Because every non-prime number is divisible by at least one prime number, so I figured I could save a lot of iterations by storing the numbers I knew to be prime and only checking new numbers against those.

(I actually don't know if I knew that about prime numbers at some point and had forgotten it, but I spent quite a few minutes going, "Wait, is that true? I think it might be! Let's see if it works.")

Also, I've been writing a lot of Ruby on Rails code, and it's possible I'm just used to using arrays for everything. :)

Post a comment in response:

This community only allows commenting by members. You may comment here if you're a member of intro_to_cs.
(will be screened if not on Access List)
(will be screened if not on Access List)
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting