## Friday, September 18, 2020

Solution Exercise 759: algorithm python to find all common divisors for two integers

#### Exercise 759

Write a python algorithm in the form of a function which takes as parameters two integers m and n which returns the list of all the divisors common to m and n.

#### Solution

``````def listCommonDivisors(m , n):
# initializing the list of all common divisors
lCommonDiv = []
for i in range(1 , m + 1):
if m%i == 0 and n%i == 0:
lCommonDiv.append(i)
return lCommonDiv

# Testing algorithm
print("The list of all common divisors of 18 and 48 is : " , listCommonDivisors(18 , 48))
# The output is : The list of all common divisors of 18 and 48 is :  [1, 2, 3, 6]``````

Younes Derfoufi
my-courses.net

## Python Exercises With Solutions

1. Python Arithmetic Exercises
2. Equations & System Of Equations
3. Polynomials and Functions
4. Python Arithmetic Exercises
5. Numpy, Matplolib, Sympy , Scipy - Exercises
6. Python Arithmetic Exercises

Younes Derfoufi

## Sample Text 