22 lines
345 B
Python
22 lines
345 B
Python
|
#!/usr/bin/env python
|
||
|
|
||
|
"""Algorithme : Détermine si un entier N est premier"""
|
||
|
|
||
|
|
||
|
def main() -> None:
|
||
|
|
||
|
print(EstPremier(47, 47 // 2))
|
||
|
|
||
|
|
||
|
def EstPremier(N : int, i : int) -> bool:
|
||
|
if i == 1:
|
||
|
return True
|
||
|
elif N % i == 0:
|
||
|
return False
|
||
|
else:
|
||
|
return EstPremier(N, i - 1)
|
||
|
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
main()
|