jeudi 8 février 2018

Python if statement without == operator

Can someone explain to me how this function does work? I can't get it how the for loop keeps going while there is return False after if statement, which is also unclear for me.

def IsPrime(n):
for x in range(2, int(n/2+1)):
    if not n % x:
        return False;
return True;

I don't understand what is happening in the line #3 of this code.

Aucun commentaire:

Enregistrer un commentaire