First Prime Number
You are given N inputs. Write a program to print the first prime number in the given inputs.
Input
The first line of input is an integer N. The next N lines each contain an integer. Explanation
In the given example of
5 integers
1
10
4
3
2
The output should be
3.
Sample Input 1
5
1
10
4
3
2
Sample Output 1
3
Sample Input 2
4
2
3
5
7
Sample Output 2
2
n = int(input("Enter a positive integer: "))
is_primes = [] # list of potential prime numbers(contains primes and non primes)
for count in range(n):
read = int(input("> "))
is_primes.append(read)
non_primes = []
for num in is_primes:
if num == 2 or num == 3:
pass
else:
for i in range(2, num):
if num % i == 0:
non_primes.append(num)
break
else:
pass
print(sum(non_primes))
Comments
Leave a comment