My backwards logic

Denis McMahon denismfmcmahon at gmail.com
Sat Sep 6 03:49:49 EDT 2014


On Fri, 05 Sep 2014 12:48:56 -0400, Seymore4Head wrote:

> But, what this instructions want printed is "This is a prime number"
> So how to I use this code logic NOT print (not prime) and have the logic
> print "This number is prime"

This is an algorithmic question, not a python question, so the answer is 
to write out the steps you would follow to determine that a number is 
prime, and then write that code.

Note also that when searching for factors of a number n, and starting at 
2, you can generally stop at somewhere around n/3, as the only possible 
factor of n greater than n/2 is n, and 2 is probably the first value you 
tested. This can speed things up.

-- 
Denis McMahon, denismfmcmahon at gmail.com



More information about the Python-list mailing list