Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Symbolic Programming. Program language being used is Haskell, would appreciate an explanation on the work if given. In this assignment, you are going to write

Symbolic Programming. Program language being used is Haskell, would appreciate an explanation on the work if given.
image text in transcribed
image text in transcribed
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 n (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 n 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, 84, 432, 576, 768, 864, 1152, 1728, 2304, 3456] 3, 23, 69, 97, 291, 2231] 12. 3, 6, 463, 926, 13891 . factor 6693 .factor 2778 .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 "CSC207a3.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.hsis listed here for your reference: Integer -Integer factor n-n 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 n (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 n 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, 84, 432, 576, 768, 864, 1152, 1728, 2304, 3456] 3, 23, 69, 97, 291, 2231] 12. 3, 6, 463, 926, 13891 . factor 6693 .factor 2778 .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 "CSC207a3.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.hsis listed here for your reference: Integer -Integer factor n-n

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions

Question

What is the difference between Needs and GAP Analyses?

Answered: 1 week ago

Question

What are ERP suites? Are HCMSs part of ERPs?

Answered: 1 week ago