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

15 lines
302 B
Python
Raw Normal View History

2022-10-14 22:03:25 +00:00
def isPrime(n):
div_counter = 0
for x in range(1, n):
if n % x == 0:
div_counter += 1
if div_counter > 1 or n == 1:
return False
else:
return True
def main():
for x in range(1, 100):
print('Is {} prime? {}'.format(x, isPrime(x)))
main()