## Transcribed Text

In this assignment, you are going to write a Haskell function factor to find all proper factors of
a positive Integer.
Given a positive Integer value n. a proper factor is defined to an Integer value i between I to
" (exclusively) such that n is divisible by i, that is, the remainder of dividing n by i is zero (0).
Note that although both 1 and " are divisible by n, they are not proper factors of n.
The function factor has the following type signature:
factor :: Integer
[Integer]
That is, it takes an Integer and returns a list of Integer. The elements in the list are all proper
factors of the parameter, and they must be in ascending order.
The followings are some examples:
factor 843
[3, 281]
factor 3281
[17, 193]
factor 6912
[2, 3, 4, 6, 8, 9, 12, 16, 18, 24, 27, 32, 36, 48,
54, 64, 72, 96, 108, 128, 144, 192, 216, 256, 288,
384, 432, 576, 768, 864, 1152, 1728, 2304, 34561
factor 6693
[3, 23, 69, 97, 291, 2231]
factor 2778
[2, 3, 6, 463, 926, 1389]
factor 4027
[]
Note that the output for the last example is an empty list since 4,027 is a prime number and it has
no proper factor.
Download the three files "CSC207a3tester hs", "csc207a3TestData. hs", and
"csc207a hs" from Canvas and save them in the same folder. The first two files are the tester
program and the testing data file, respectively. Do not modify these two files. The last 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 don't modify it.
The file "csc207a3. 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 "csc207a3. hs" is listed here for
your reference:
module CEC207a3 where
factor : Integer -> [Integer]
factor n Inl
The tester program will use the test data to test your implementation. It will run a total of 100 test
cases. To see the result, just load the tester into GHCi and ask it to show the value of results. If
your function is implemented correctly, it should produce the following output:
Prelude> : load "csc207 Gtester. hs
[1 of 3] Compiling CSC2D7 3TestDat ta
csc207a3TestDats hs, interpreted )
[2 of 3] Compiling CSC2D7a3
csc207a3.hs, interpreted
[3 of 3] Compiling csc207a3tester
csc207aStester.hs, interpreted
ok,
modules
loaded:
csc207a3tester, csc207a3, CSC2D7a3TestData
*OSC2D7a3tester> results
The result contains a tuple of three values. The first (highlighted in
is a floating point
value representing your score (on a scale of 15 points). The second (highlighted in blue) is a list
of all test cases that you passed. The third (highlighted in
is a list of all test cases that you
failed.
If you would like, you can look up the test data from the file csc207a3TestData hs. This file
defines a single list named tests, which consists 100 tuples. Each tuple is a test, and it has three
(3) values inside:
The first is an integer representing the test id.
The second is the value of n representing the parameter to the function.
The third is a list representing the expected result of calling factor using the input
parameters.
The following is the first few lines in the test data file:
module CSC2OTaTestData where
tests :: (Integer, Integer, [Integer]]
tests - [< 1, 843, [3, 281]),
(2,3281,[17,1931),
3,6912, [2, 3, 4, 6, 8, 9, -., 1152, 1728, 2304, 345611,
4,6693, (3, 23, 69, 9T, 291, 2231]1,
5, 2778, [2, 3, 6, 463, 926, 138911,
6,4027,01,

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction
of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice.
Unethical use is strictly forbidden.

module CSC207a3 where

factor :: Integer -> [Integer]

factor n = alldivisors n

-- factor n = [n]

isqrt :: Integer -> Integer

isqrt x = floor (sqrt (fromIntegral x))

divisor :: Integer -> Integer -> Integer

divisor x y = if 0 == x `mod` y

then y...