You are given n inputs, write a program to print the first prime number in the given inputs.
In the given example of 5 integers.
5
1
10
4
3
2
Output should be
3
num = []
while True:
c = input('Please, input how many integers you want to check => ').strip()
if c.isdigit():
c = int(c)
break
else:
print('You should input integer number')
print()
while len(num) != c:
n = input('Please, input any number => ').strip()
if n.isdigit():
num.append(int(n))
else:
print('You should input number!')
result = 'Any of your number are not prime'
for n in num:
if n != 1:
counter = 0
for i in range(1, n+1):
if n % i == 0:
counter += 1
if counter > 2:
break
if counter == 2:
result = str(n)
break
if result.isdigit():
print(result)
else:
print(result)
Comments
Leave a comment