Question: 4) Define function commonDiv that receives two numbers as input, and returns the list of all common divisors of those two input numbers. For example

4) Define function commonDiv that receives two numbers as input, and returns the list of all common divisors of those two input numbers. For example if the inputs are 24 and 30, the output would be [1,2,3,6]. You may use list comprehension and function divisor defined earlier. Hint: Given numbers n and m, generate the list of divisors of these numbers and only keep the intersection.

(5) Define function greatestCommonDiv that receives two numbers as input and returns the greatest common divisor of those two input numbers. For example, if the inputs are 24 and 30, then the output would be 6. You may use maximum function along with commonDiv defined earlier.

Note: function gcdis already part of standard library. Do not use that! Hint: Given numbers n and m, call commonDiv on them and return the biggest element of that list.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!