Multiples of 3
You are given N inputs. Print the numbers that are multiples of 3.
Input
The first line of input is an integer N. The next N lines each contain an integer as input.
Explanation
In the given example, there are
6 inputs. 1, 2, 3, 5, 9, 6. The numbers 3, 9, 6 are multiples of 3. So, the output should be
3
9
6
Sample Input 1
6
1
2
3
5
9
6
Sample Output 1
3
9
6
Sample Input 2
4
1
3
6
8
Sample Output 2
3
6
n = int(input())
output = []
for _ in range(n):
a = int(input())
if not a % 3:
output.append(a)
print(*output, sep='\n')
Comments
Leave a comment