You are given N inputs. Write a program to print the first prime number in the given inputs.
The first line of input is an integer
N. The next N lines each contain an integer.
def is_prime(x):
i = 2
while i <= int(x ** 0.5):
if x % i == 0:
return False
i += 1
return True
n = int(input('N='))
primes = []
for i in range(n):
x = int(input())
if is_prime(x) and x != 1:
primes.append(x)
if len(primes) > 0:
print('the first prime number= ', primes[0])
else:
print('There are no prime numbers')
Comments
Leave a comment