Explanation plz (im sorry i don't get it)


#1



def is_prime(x):
    if x < 2:
        return False 
    elif x == 2:
        return True
    else:
        count = 0 
        for n in range (2,x):
            if float(x) % float(n) == 0:
                count += 1 
        if count == 0:
            return True
        else:
            return False
print is_prime(999999)

what does float mean?


#2

float() will cast integers to floats, you can always add print statements to see what something is doing:

for n in range (2,x):
    print x, float(x), n, float(n)

#3

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