I work on a windows XP PC with a Python 2.6 install and I was trying to solve a Project Euler problem, but whenever I execute the code the interpreter hangs. I've debugged it through PyScripter, IDLE and MonkeyStudio, but it still doesn't work even for trivial values like 15.
I simply don't understand why. Can you please help me out?
Here's the code:
"""Project Euler Problem 3
Author: A"""
num = 15
prime = [1]
x = long (round(num/2))
def ifprime (x):
""" Defining the function that checks if the number is prime or not"""
""" Checking if the passed number is prime or not"""
y = long(round(x/2))
while y > 0:
if x%y == 0:
return False
y -= 1
return True
while x > 0:
if num%x == 0:
if ifprime(x):
print "I've found a prime! "
print x
prime[len(prime):] = [x]
x -= 1