uaveiro-leci/1ano/1semestre/fp/aula04/isprime.py

17 lines
279 B
Python
Raw Normal View History

2022-10-14 22:03:25 +00:00
def isPrime(n):
2023-02-25 11:41:27 +00:00
if n == 1:
return False
2022-11-10 23:20:38 +00:00
for x in range(2, n):
2022-10-14 22:03:25 +00:00
if n % x == 0:
2022-11-10 23:20:38 +00:00
return False
return True
2022-10-14 22:03:25 +00:00
def main():
for x in range(1, 100):
print('Is {} prime? {}'.format(x, isPrime(x)))
2022-11-10 23:20:38 +00:00
if __name__ == "__main__":
main()