Objectives: Learn how to write simple function using GP
Your assignment is to write a simple function using GP.
Your function should be named wilsonquotientfactors, and its arity is two; thus your definition should look something like:
wilsonquotientfactors(r,s) = { local( .. , .. , .. ); ... [ code ] ... }
We will define a "Wilson Quotient" wq(x) as
wq(x) = [(x-1)! + 1] / x
The output of your function wilsonquotientfactors is based on treating r and s as specifying a range; over each i in that range from r to s, you should print the factorization of wq(i) if wq(i) is an integer, or a message that wq(i) is not an integer.
For instance, your GP function should return output for wilsonquotientfactors(10,30) as:
? wilsonquotientfactors(10,30) wilsonquotient(10) = 362881/10 is not an integer factors of wilsonquotient(11) = Mat([329891, 1]) wilsonquotient(12) = 39916801/12 is not an integer factors of wilsonquotient(13) = [13, 1; 2834329, 1] wilsonquotient(14) = 6227020801/14 is not an integer wilsonquotient(15) = 87178291201/15 is not an integer wilsonquotient(16) = 1307674368001/16 is not an integer factors of wilsonquotient(17) = [61, 1; 137, 1; 139, 1; 1059511, 1] wilsonquotient(18) = 355687428096001/18 is not an integer factors of wilsonquotient(19) = [23, 1; 29, 1; 61, 1; 67, 1; 123610951, 1] wilsonquotient(20) = 121645100408832001/20 is not an integer wilsonquotient(21) = 2432902008176640001/21 is not an integer wilsonquotient(22) = 51090942171709440001/22 is not an integer factors of wilsonquotient(23) = [521, 1; 93799610095769647, 1] wilsonquotient(24) = 25852016738884976640001/24 is not an integer wilsonquotient(25) = 620448401733239439360001/25 is not an integer wilsonquotient(26) = 15511210043330985984000001/26 is not an integer wilsonquotient(27) = 403291461126605635584000001/27 is not an integer wilsonquotient(28) = 10888869450418352160768000001/28 is not an integer factors of wilsonquotient(29) = Mat([10513391193507374500051862069, 1]) wilsonquotient(30) = 8841761993739701954543616000001/30 is not an integer ?
(Bonus question: what characteristic of i seems to govern whether or not wq(i) is an integer?)
Specifications: The file containing your GP code should be called Assign6.gp.
Homework submission
Please mail your file Assign6.gp as an attachment to langley@cs.fsu.edu by no later than the beginning of class on Thursday, December 4.
If you have an answer to the bonus question, please include it as a comment in the file Assign6.gp.