## Monday, September 14, 2020

Solution Exercise 86: python algorithm to searche the list of all common divisors of given two integers

#### Exercise 86

Write a Python algorithm that determines the list of all common divisors of two given integers m and n.

#### Solution

``````def commonDivisors(m , n):
# Initialize the list of common divisors of m and n
listCommonDiv = []
# It is the same to choose m, n or min(m,n) as loop limit
for i in range(1 , m):
if (m%i == 0 and n%i == 0):
listCommonDiv.append(i)
return listCommonDiv
# Testing algorithm
print("The list of common divisors of 36 and 24 is : " , commonDivisors(36 , 24))
# The output is : The list of common divisors of 36 and 24 is :  [1, 2, 3, 4, 6, 12]``````

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 