Is_prime


#1



Not sure what I did wrong. Can someone please help? Thanks!
Here is my code(Not sure if i'm posting right):


def is_prime(x):
    if x < 2:
        return False
    elif x == 2:
        return True
    else:
        for n in range(2, x):
            if x % n == 0:
                return False
            else: 
                return True


#2

Your loop's if statement should not have an else branch.


#3

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