You are given N inputs. Write a program to print the first prime number in the given inputs
def isPrime(n):
if n % 2 == 0:
return n == 2
d = 3
while d * d <= n and n % d != 0:
d += 2
return d * d > n
N = int(input())
t = []
for _ in range(N):
t.append(int(input()))
for num in t:
if isPrime(num):
print(num)
break
Comments
Leave a comment