#C2661. Divisible By Others
Divisible By Others
Divisible By Others
You are given a list of integers. Your task is to find and output all the integers in the list that are divisible by at least one other distinct integer in the same list.
An integer a is said to be divisible by another integer b (with b ≠ 0) if there exists an integer \(k\) such that \(a = b \times k\). In other words, \(b\) divides \(a\) if \(a \bmod b = 0\).
Note: When checking for divisibility, do not consider an integer dividing itself; only consider other positions in the list.
Example:
Input: 6 2 3 8 6 12 7</p>Output: 8 6 12
inputFormat
The first line of input contains an integer \(n\) representing the number of elements in the list. The second line contains \(n\) space-separated integers.
outputFormat
Output a single line containing the numbers (in the same order as they appear in the input) that are divisible by at least one other number from the list, separated by a single space. If no such numbers exist, output an empty line.
## sample6
2 3 8 6 12 7
8 6 12
</p>