delegbede at dudupay.com
Tue Jul 13 11:50:28 CEST 2010
I was trying to write a code that prints prime numbers between 1 and 20.
I have by myself seen that something is wrong with my code and also my
Could anyone be kind enough to tell me what to do....
Where I am confused is how to test for other numbers without one and the
number itself. It turns out that all numbers pass the condition I set so
that would presuppose that all numbers are prime which is not.
How exactly can I get it to run checks with other numbers such that it
doesn't include the number itself and 1.
The code is as follows:
for i in range(1,20):
if float(i) % 1 == 0 and float(i) % i == 0:
print i, 'is a prime number'
Elegbede Muhammed Oladipupo
Mobile Banking Solutions | Transaction Processing | Enterprise Application
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor