Class Forum
» Ps2: I'm a little confused here. I'm getting it to loop
This code keeps looping in the 4th line. Don't understand why. Can anyone help ? (I don't want a solution tough, just guidance....
Counter=0
Prime=3
while (Counter<1000): #as long as the number of found primes is less than 9
if (Prime%2)==0: #if the number is even or odd
Prime=Prime+1 #go to the next prime
else: #if the prime is not even, which means odd
for div in range(2, (Prime/2)+1):
if Prime%div==0:
Prime=Prime+1
else:
Prime=Prime+1
Counter=Counter+1
print Prime
Reply
* Markdown Cheatsheet:
Link:
[clickable text](http://www.example.com)
New Paragraph:
Hit enter twice
Main heading:
# Main Heading Text
Sub-heading:
## Sub-heading Text
List:
* item 1
* item 2
* item 3
Italics:
*italicized text*
Bold:
**bold text**
YouTube:
URL (http://www.youtube.com/watch?v=Ui4AYPcRkYE) turns into embed code
Full Markdown reference
|