提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
欧几里得的最大除数(GCD)
public class Main { /* *来 自 时代Java */ 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; } // Display to console System.out.println("Greatest common divisor is " + a); } }