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

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!