Write a program that takes as input a positive integer m and
Write a program that takes as input a positive integer m and a polynomial f(X) having integer coefficients and produces as output all of the solutions to the congruence f(X) = 0 (mod m). (Don\'t try to be fancy. Just substitute X = 0, 1, 2, ..., m - 1 and see which values are solutions.) Test your program by taking the polynomial f(X) = X11 +21X7 - 8X3 + 8 and solving the congruence f(X) = 0 (mod m) for each of the following values of m, m {130, 137, 144, 151, 158, 165, 172}
Solution
Answer to Part 1 :
Let us call A = f (X) = X11+ 21 X7 - 8 X3 + 8 .
Let us take and substitute the value of X=2 from the set X= 0, 1 2, 3...m-1.
A= f(2) = 211 + 21 (2)7 - 8 (2)3 + 8 = 2048 + 2688 - 64 + 8 = 4680
Given f(X) 0 (mod 130) , Here I have taken m = 130.
Now , A 0 (mod 130)
4680 0 (mod130)
4680/130 = 36.
We can now write a program to solve in the similar way.
A 0 (mod m)
A- 0 / m = k (some integer).
A= mk.
X11+ 21 X7 - 8 X3 + 8 = mk
X11+ 21 X7 - 8 X3 = mk - 8.--- (1).
In the above equation 1 we input the values of m and the values of X to get the value of k as integer.
