Question: Consider the following two methods that compute the greatest common divisor of two integers. GCD(a, b) { n = min(a, b): for (int i =


Consider the following two methods that compute the greatest common divisor of two integers. GCD(a, b) { n = min(a, b): for (int i = n: i > = 1: i--) if both a%1 and b%i are zero, return i: } Fastgcd (a, b) { if b equals 0, return a, else return Fastgcd(b, a %b): } Write a Java program that implements both of the above methods. Play with the program by giving very large numbers as inputs to both the numbers. (a) Pick two 9-digit primes and run both methods. Report the run time. (b) Pick two 10-digit primes and run both methods. Report the run time. (c) Show that the run time of FastGcd is O(n) when the inputs a and b are n-bit integers. Please do not submit your code. You can use System.currentTimeMillis() to calculate run time of your methods. You can look at https: //primes.utm.edu lists/small/millions/ for 9 digit primes. You can look at https: /primes.utni.edu/lists/small small.html for 10 digit primes
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
