Question: import java.util.*; import java.lang.Math; public class JavaApplication { private static Scanner input = new Scanner(System.in); public static void main(String[] args) { int a; int b;
import java.util.*; import java.lang.Math;
public class JavaApplication { private static Scanner input = new Scanner(System.in);
public static void main(String[] args) { int a; int b; System.out.println("Enter two numbers. This algorithm will find the greatest common denominator."); a = input.nextInt(); b = input.nextInt(); while (!(b == 0)) { if (a > b) { a = a - b; } else { b = b - a; } } System.out.println(a); } }
JAVA coding! Could anyone explain to me step by step on how this Great Common Divisor code in Java works?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
