Common Divisors
InterviewTime limit1sMemory limit256 MB
Given 2 or 3 numbers up to 1e8, print every positive integer that divides all of them, in increasing order.
- Level
Easy3 of 10
- Topics
- Math, Number theory, Sorting, Brute force
- Solved
- No attempts yet
Problem
You are given natural numbers. Write a program that finds all of their common divisors.
Input
The first line contains , which is either 2 or 3. The second line contains the natural numbers whose common divisors you must find. Every number is at most .
Output
Print the common divisors of the given numbers, one per line, in increasing order.