Is a_prime


#1



def is_prime(x):
    if x<=1:
        return False
    elif x == 2:
        return True
    elif x > 2:
        i=0
        while x>i:
            i=2
            if float(x)/i == int(x/i):
                return False
                break
            i = i+ 1
        else:
            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.


#2

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

while x>i:
   i=2

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: