Array Elements - Divisible by D

 Coding Problem Keys 

 Array Elements - Divisible by D 

 Problem Statement 

An array of N positive integers are passed as input. D which is a positive integer is also passed as the input. The program must print the elements in the array which are divisible by D.

 Boundary Condition(s) 

2 <= N <= 10000
1 <= D <= 9999

 Input Format 

The first line contains the value of N.
The second line contains the N values, each separated by a space.
The third line contains the value of D.

 Output Format 

The first line contains the elements among the array which are divisible by D, with each value separated by a space.

 Example Input/Output 1 

 Input 

6
10 20 30 40 50 60
4

 Output 

20 40 60

 Note: Max Execution Time Limit: 5000 millisecs 

 Solution 

 Programming Language: Python 3 Language 

n=int(input())
l=list(map(int,input().split()))
d=int(input())
print(*[i for i in l if i%d==0])

# Published By PKJCODERS

 (Note: Incase If the code doesn't Pass the output kindly comment us with your feedback to help us improvise.) 

Comments

Popular Posts

Print Prime Numbers from 2 to N

Count Number of Occurrences of a Character

Mixed Matrix - Integers & Characters

Most Vowels in Row

Highly Profitable Months

Print Matrix - Diagonal Zig Zag