IS_prime


#1



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


Replace this line with your code.


#2

What is the problem you need to solve?


#3

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

#5

Thus would solve

def is_prime(x):
if x>2:
for num in range(2,x):
print num
if x%num==0:

            break
        else:
            continue
    if num==x-1:
        return True
    else:
        return False
elif x==2:
    return True
else:
    return False

#6

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