package com.xiaojihua.datastructure; public class Gcd { public static void main(String[] args) { // TODO Auto-generated method stub long rem = gcd(1989,1590); System.out.println(rem); } /** * 歐幾里得算法,求兩個整數的最大公因數 * @param m * @param n * @return */ public static long gcd(long m,long n){ while(n != 0){ long rem = m%n; m = n; n = rem; } return m; } }