Question
Please help. In Haskell (1) Use list ranges for the following (a) List of all positive multiplicands of 5 that are less than 200. (b)
Please help. In Haskell
(1) Use list ranges for the following
(a) List of all positive multiplicands of 5 that are less than 200. (b) List of all odd numbers between 300 and 250 in descending order.
(2) Use list comprehension for the following
(a) List of all positive multiplicands of 5 that are less than 200. (b) List of all odd numbers between 300 and 250 in descending order.
In the following three questions, we are aiming to define greatest common divisor of two numbers, in a step-by-step fashion.
(3) Define function divisors that receives a number and returns a list of all divisors of that number. For example, if the input is 20, then the output would be [1,2,4,5,10,20]. You may use list comprehension, list ranges, and function mod for this purpose. Hint: Given number n, consider all numbers from 1 to n, and then keep only the ones that divide n.
(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 gcd is 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started