Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this assignment, you are going to write a Haskell function named factors to find all proper factors of a positive Integer. Given a positive
In this assignment, you are going to write a Haskell function named factors to find all proper factors of a
positive Integer.
Given a positive Integer value a proper factor of is defined to be an Integer value i between to
exclusively such that is divisible by ; that is the remainder of dividing by is zero Note that although
is divisible by both and they are not proper factors of
The function factors has the following type signature:
factors :: Integer Integer
That is it takes an Integer as its only parameter and returns a list of Integers. The elements in the list are
all proper factors of the parameter, and they must be all unique and in ascending order.
Here are some examples:
factors
factors
factors
factors
factors
Note that the output for the last example is an empty list since is a prime number and it has no proper
factor.
Download the three files CSCahsCSCaTester.hs and CSCaTestData.hs from
Canvas and save them in the same folder. The last two files are the tester program and the test data file,
respectively. Do not modify these two files. The first file is the file you will work on Note that you cannot
rename this file and you cannot change the name of the function otherwise the tester will not be able to pick
up your implementation However, you can change the names of the parameters if you like. Also note that
the first line is required for the tester to locate your code so do not modify it
The file CSCa hs contains a dummy implementation of the function that always returns a singleton list
with the input parameter as its only element since a value cannot be a proper factor of itself, it is always
incorrect The contents of the file CSCahs is listed here for your reference: factors :: Integer Integer
factors n n
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