Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me in Haskell code (4) Define functioncommonDivthat receives two numbers as input, and returns the list of all common divisors of those two

Please help me in Haskell code

(4) Define functioncommonDivthat 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 functiongreatestCommonDivthat 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 withcommonDivdefined earlier.Note: function gcd is already part of standard library. Do not use that! Hint:Given numbers n and m, callcommonDivon them and return the biggest element of that list.

-----

Example : len xs = sum [1| _ <- xs] -- length of the list

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mastering Big Data Interview 751 Comprehensive Questions And Expert Answers

Authors: Mr Bhanu Pratap Mahato

1st Edition

B0CLNT3NVD, 979-8865047216

More Books

Students also viewed these Databases questions