you are given N inputs. wirte a program to print first prime number in given inputs.
Input 1
5
1
10
4
3
2
input 2
4
2
3
5
7
def is_prime(num):
if num > 1:
if num == 2:
return True
for i in range(2,num):
if (num % i) == 0:
return False
else:
return True
else:
return False
is_prime(2)
N = int(input('Enter number here: '))
list1 = []
for i in range(N):
j = int(input('Enter integer here: '))
list1.append(j)
for i in list1:
if is_prime(i) == True:
print(i)
Enter number here: 6
Enter integer here: 5
Enter integer here: 1
Enter integer here: 10
Enter integer here: 4
Enter integer here: 3
Enter integer here: 2
5
3
2
Comments
Leave a comment