Question: Write a java method that returns the largest n-digit coprime for a given integer. The integer for which the largest co-prime is being searched is

Write a java method that returns the largest n-digit coprime for a given integer. The integer for which the largest co-prime is being searched is passed as the first argument to the method and the second argument is the number of digits. In case, an n-digit coprime is not possible, -1 is returned.

For all other error situations, return -2. Cannot use for loops in this question; use while or do-while.

Cannot use any Math libraries in this method.

Cannot use the system.exit(0) anywhere in the method

Cannot use input/output in method (use main to test)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!