Is_prime infinite loop


#1



Hey guys
This code is showing an error message hat check the code for an infinite loop but when i call the function it works perfectly.
Please help!



def is_prime(x):
    n = 2
    while n != x and n>=1:
        if x%n == 0:
            return False
            n += 1
    else :
        return True

Thanks


#2

This line is the main problem I would suggest using a for loop for a more controlled output.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.