Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write code in JAVA oriented Do not worry about writing doc comments. Consider a prime number, say p. With arithmetic modulo p, the integers in
Write code in JAVA oriented
Do not worry about writing doc comments. Consider a prime number, say p. With arithmetic modulo p, the integers in the interval (0.p) are a specially named set called the residue classes of p. Note that this is just a fancy way of saying that the possible remainders when dividing any integer by p are just 0, 1, 2,.... (P-2), or (p-1). For example, the possible remainders when dividing by 3 are just 0, 1, or 2. For some prime p, it is always true that any integer a in 1.p) has a unique inverse modulo p, say b in 1. p). In other words, a and b are such that (ab%p) = 1. Note that it may be the case a = b. Another way to say this is that the product ab is exactly one more than some multiple of p. Create a class named Residue with a class constant integer P = 11. Inside this class, create a statie method searchFor Inverses that takes an ArrayList of Point 2D instances as a parameter. Use loops to try every possible pair of integers in the interval (1,P) to test if they are inverses of each other modulo P. For every such pair of a and b you discover, create a Point2D to add to the parameter collection of points as (a,b). It is fine to have duplicate pairs (b, a) from your loop executions, which will simplify your code. In the Residue class, write another static method named print Inverses that takes no parameters. In this method, create an ArrayList for collecting Point 2D and first initialize it as empty. Pass this collection in a call to your searchFor Inverses method, so that this can fill it with the inverse pairs it will find. Then have your printInverses method print out the following for each inverse pair in the collection: the pair as a coordinate, with parentheses: (a,b), the product for ab, the multiple of p plus 1 that equals ab (hint: ab - 1). Create another class named Main, and have it be where your program begins execution. Have it call your print Inverses through the Residue class. An example of nice output for your program if P = 9: (1, 1): (2, 5): (4, 7): (5, 2): (7, 4): (8, 8): 1-1 = 1 = 2*5 = 10 = 4*7 = 28 = 5*2 = 10 = 7*4 = 28 = 8*8 = 64 = 90 + 1 9*1 + 1 9.3 + 1 9*1 + 1 9.3 + 1 9.7 + 1 Do not worry about writing doc comments. Consider a prime number, say p. With arithmetic modulo p, the integers in the interval (0.p) are a specially named set called the residue classes of p. Note that this is just a fancy way of saying that the possible remainders when dividing any integer by p are just 0, 1, 2,.... (P-2), or (p-1). For example, the possible remainders when dividing by 3 are just 0, 1, or 2. For some prime p, it is always true that any integer a in 1.p) has a unique inverse modulo p, say b in 1. p). In other words, a and b are such that (ab%p) = 1. Note that it may be the case a = b. Another way to say this is that the product ab is exactly one more than some multiple of p. Create a class named Residue with a class constant integer P = 11. Inside this class, create a statie method searchFor Inverses that takes an ArrayList of Point 2D instances as a parameter. Use loops to try every possible pair of integers in the interval (1,P) to test if they are inverses of each other modulo P. For every such pair of a and b you discover, create a Point2D to add to the parameter collection of points as (a,b). It is fine to have duplicate pairs (b, a) from your loop executions, which will simplify your code. In the Residue class, write another static method named print Inverses that takes no parameters. In this method, create an ArrayList for collecting Point 2D and first initialize it as empty. Pass this collection in a call to your searchFor Inverses method, so that this can fill it with the inverse pairs it will find. Then have your printInverses method print out the following for each inverse pair in the collection: the pair as a coordinate, with parentheses: (a,b), the product for ab, the multiple of p plus 1 that equals ab (hint: ab - 1). Create another class named Main, and have it be where your program begins execution. Have it call your print Inverses through the Residue class. An example of nice output for your program if P = 9: (1, 1): (2, 5): (4, 7): (5, 2): (7, 4): (8, 8): 1-1 = 1 = 2*5 = 10 = 4*7 = 28 = 5*2 = 10 = 7*4 = 28 = 8*8 = 64 = 90 + 1 9*1 + 1 9.3 + 1 9*1 + 1 9.3 + 1 9.7 + 1Step 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