Is a_prime


def is_prime(x):
    if x<=1:
        return False
    elif x == 2:
        return True
    elif x > 2:
        while x>i:
            if float(x)/i == int(x/i):
                return False
            i = i+ 1
            return True

I don't know but when I run this code following error is appearing.
The program took too long to finish. Check your code for infinite loops and try again.

Replace this line with your code.


each time your loop resets i to 2, because of this line:

while x>i:

yea, you increase i, but then this effect is smashed by the i=2, since that is inside the loop, which means it is executed each time. You need to set i outside the loop:

i = 2
while x > i: