[Tutor] prime test problem
rwobben at hotmail.com
Sat Aug 21 19:14:05 CEST 2010
I tried it with this simple programm
while x <= int(n**0.5)+1:
if n % x == 0:
print 7, "is een prime getal"
print 7, "is geen prime getal"
But this one gets in a indefinitive loop.
> From: steve at pearwood.info
> To: tutor at python.org
> Date: Sun, 22 Aug 2010 02:49:26 +1000
> Subject: Re: [Tutor] prime test problem
> On Sun, 22 Aug 2010 12:41:03 am Roelof Wobben wrote:
> > Hello,
> > I know.
> > I have read them all I believe
> You've read all 64 million pages that Google finds? Wow, you must be a
> fast reader! Well done!
> > but I can't see how I can convert the
> > algebra to a working programm.
> Have you *tried*?
> Perhaps you should try something a little bit less ambitious. Write a
> program to test whether a number is divisible by 3. Then write a
> program to test whether a number is divisible by 3 or 5. Then write a
> third program to test whether a number is divisible by 3, 5 or 7.
> Then generalise that third program.
> Off you go. Come back when you have some code. Even if it isn't working
> code, at least try something.
> Steven D'Aprano
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor