fb pixel

Common divisors

Given two numbers, you are asked to find the common divisors of those two.
The input contains 2 numbers.
The program should print the list of the common divisors without repetitions in increasing order separated by a space.
Input
Output
6 12
1 2 3 6
8 12
1 2 4
Tip
Create a function def divisors(n): that would return a list of divisors of that number. Use this function to get the divisors for both numbers. div_a = divisors(a) and same for b.
 
To check your solution you need to sign in
Sign in to continue