Java examples for Language Basics:Operator
Euclid's Greatest Common Divisor (GCD)
public class Main { public static void main(String[] arg) { int a = 32; int b = 24; System.out.println("Computing GCD(" + a + "," + b + ")"); while (a != b) { if (a > b) a = a - b; else b = b - a; }/*from ww w . j a v a 2s . c o m*/ // Display to console System.out.println("Greatest common divisor is " + a); } }