The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



Thread: Python
View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 04-14-2002
thehoghunter
Guest
 

Posts: n/a
First - I have no idea what Python is.
Second - that means I have no idea of it's syntax.

BUT -

As Spock would say "Logic suggest..."

This code you posted:

if (i % j) == 0:
print j,
else:
if j == i + 1:
print "is a Prime"


IF it prints j, you will never go to the else. Logic is logic -

if (true) then do this ELSE do this - you need to change this so it looks at each separately or looks at the second within the if

if (true) then
print j
if (true) then
print "is a Prime"
Reply With Quote