[Tutor] Help
Dipo Elegbede
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
brain.
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
OCA
+2348077682428
+2347042171716
www.dudupay.com
Mobile Banking Solutions | Transaction Processing | Enterprise Application
Development
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100713/a3b91d13/attachment.html>
More information about the Tutor
mailing list