def isprime(x): for a in range(2,(x//2)+1): if((x<=0) or (x%a==0)): return(False) return(True)
This does not work for negative values . for eg: isprime(-3) returns True but it has to return False. please help.
isprime(-3)
True
False
Aucun commentaire:
Enregistrer un commentaire