![]() |
|
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Feb 2006
Posts: 5
Rep Power: 0
![]() |
KeyboardInterrupt when calling a function
Hi, I am toying with the following program to generate prime numbers:
import sys
from math import sqrt, floor
def prime_gen(count):
num = 2
ct = 0
while ct < count:
for i in range(2, int(floor(sqrt(num)))):
if num % i == 0:
num = num + 1
elif num % i != 0:
print num
ct = ct + 1
num = num + 1
prime_gen(100)
#x = int(sys.argv[1])
#prime_gen(x)When I call prime_gen at the prompt (=execute the program), the prompt freezes and I have to exit it with Ctrl+C. The error message says there is a KeyboardInterrupt and the lines 17 and 9 cause the problem, I however do not understand WHAT the problem is - thanks beforehand for help. V. |
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|