60 lines
1.1 KiB
Python
60 lines
1.1 KiB
Python
#!/usr/bin/env python
|
|
#-*- coding:utf8-*-
|
|
|
|
# ------------------------------
|
|
# Imports
|
|
# ------------------------------
|
|
|
|
# ------------------------------
|
|
# Classes
|
|
# ------------------------------
|
|
|
|
# ------------------------------
|
|
# Fonctions
|
|
# ------------------------------
|
|
|
|
def estPremier(n):
|
|
""" estPremier
|
|
|
|
Test si le nombre est un nombre premier
|
|
|
|
"""
|
|
if n == 2:
|
|
return True
|
|
elif n <= 1:
|
|
return False
|
|
elif n % 2:
|
|
return False
|
|
|
|
i = 3
|
|
print("ici")
|
|
while (i*i<=n) & (n%i != 0):
|
|
i = i+2
|
|
print("la " + str(i))
|
|
|
|
if n%i ==0 :
|
|
return False
|
|
else:
|
|
return True
|
|
|
|
|
|
|
|
# ------------------------------
|
|
# Bloc principal
|
|
# ------------------------------
|
|
|
|
if __name__ == '__main__':
|
|
for i in range(30):
|
|
print("{i}, {prems}".format(i = i, prems = estPremier(i)))
|
|
|
|
|
|
# ------------------------------
|
|
# Fin du programme
|
|
# ------------------------------
|
|
|
|
# -----------------------------
|
|
# Reglages pour 'vim'
|
|
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
|
# cursor: 16 del
|
|
|