Is_prime infinite loop


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



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


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