分享一個大牛的人工智能教程,零基礎!通俗易懂!風趣幽默!希望你也加入到人工智能的隊伍中來!請輕擊http://www.captainbed.net
package live.every.day.Programming;
/**
* 題目:
* 一行代碼求兩個數的最大公約數,
*
* 思路:
* 輾轉相除法,
*
* @author Created by LiveEveryDay
*/
public class OneLineCodeGCD {
public static int gcd(int m, int n) {
return n == 0 ? m : gcd(n, m % n);
}
public static void main(String[] args) {
int m = 32875;
int n = 325;
System.out.printf("The result is: %d", gcd(m, n));
}
}
// ------ Output ------
/*
The result is: 25
*/
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/423339.html
標籤:AI
上一篇:ADP530X功能分類匯總
