Nb entier, Calculabilité & décidabilité

 avatar
unknown
python
a year ago
237 B
4
Indexable
def isprime(n):
# on élimine les cas triviaux
if n < 2 : return False
if n % 2 == 0 : return False
# on teste tous les diviseurs possibles (il y a beaucoup plus efficace !)
for d in range(3,n,2):
if n % d == 0 : return False
return True
Editor is loading...
Leave a Comment