Greatest common divisor · 最大公約数
Greatest common divisor
The GCD of two numbers is the largest integer that divides both. Euclid's algorithm is beautifully short: while b isn't 0, replace the pair (a, b) with (b, a % b). When b reaches 0, a is the answer.
最大公約数
2つの整数の最大公因数は、両方を割り切る最大の整数です。ユークリッドの互除法は非常に簡潔です:b が 0 でない間、ペア (a, b) を (b, a % b) に置き換えます。b が 0 になったとき、a が答えになります。
Complete int gcd(int a, int b) to return the greatest common divisor of a and b. Euclid's method: repeatedly replace (a, b) with (b, a % b) until b is 0. · int gcd(int a, int b) を完成させてa とb の最大公約数を返してください。ユークリッドの手法:(a, b) を(b, a % b) に繰り返し置き換え、b が0 になるまで続けます。
Click Run to see the output here. · 実行ボタンをクリックして出力を確認してください。