can i get code for this
input:
4
2
3
5
7
output:2
with following steps:
Read the Input into a variable.
Now using the loop iterate in range 1 to input.
Again read the second input into the variable.
Now take the count to assign the value 0 to it.
Using loop condition iterate from range 1 to second input.
using the if condition checks the condition that the second input is divisible by number then increment the count.
If the count is equal to 2
print the number and break from the loop.
n = int(input())
lst = []
count = 0;
for i in range(n):
x = int(input())
if x % 2 == 0:
lst.append(x)
count = count + 1
for i in lst:
print(i, end=" ")
Comments
Leave a comment