Question
Java Coding- Euclid's Algorithm Euclid's algorithm computes the greatest common divisor of two input positive integers. The greatest common divisor is the largest positive integer
Java Coding- Euclid's Algorithm
Euclid's algorithm computes the greatest common divisor of two input positive integers. The greatest common divisor is the largest positive integer that divides evenly into both of the input values.
The algorithm uses the Definition of Division, which states that for any two integers a and b, there exist integers q and r such that a = q ( b ) + r. In this representation, q is the quotient and r is the remainder.
Given two positive integers a and b, the algorithm proceeds as follows:
- For the given values of a and b, apply the Definition of Division and compute the quotient q and remainder r;
- If r > 0, then update a and by by assigning the value of b to a and also assigning the value of r to b, and then repeat Step 1 with the updated values.
- If r = 0, then the greatest common divisor of the original a and b is the last computed non-zero value for r.
- Create a Java project in Eclipse called "Euclid"
- Create the class "Euclid" in the "src" subfolder of the package (Eclipse will put this class in the file Euclid.java)
- Run your Java code in Eclipse using a run configuration that passes 2 sample inputs
- Open a command window and navigate to your desktop
- Test your JAR by running it with some sample input values, for example: "java -jar Euclid.jar 5763 187"
- Verify that your JAR contains your Java source file by using the "jar tvf
" command
***REQUIRED OUTPUT***
The main method should output the following as the output header:
- an empty line
- a line of just hyphens (dashes)
- another empty line
- the words "Euclid's Algorithm by " followed by your name (or names, if teaming
- another empty line
- the word "Inputs: " followed by the two input values in the order they were input, separated by a comma
- another empty line
Euclid's Algorithm by
Step 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