メインコンテンツへスキップ
Z

LCM vs GCD

LCM vs GCD compared — least common multiple vs greatest common divisor, formulas and uses, with a free calculator.

The GCD (greatest common divisor) is the largest number that divides two values; the LCM (least common multiple) is the smallest number both divide into. They are linked: LCM(a,b) × GCD(a,b) = a × b.

LCM vs GCD at a glance

LCM GCD
Meaning Smallest common multiple Largest common divisor
Always ≥ both numbers ≤ both numbers
Used for Adding fractions, cycles Simplifying fractions

When to use LCM

Use the LCM to find a common denominator or when two cycles re-align.

When to use GCD

Use the GCD to simplify a fraction or split into equal groups.

Tools for LCM & GCD

LCM vs GCD

ユークリッドの互除法とは何ですか?

2つの整数の最大公約数(GCD)を求める方法で、大きい方の数を、それを小さい方の数で割った余りに置き換える操作を、余りが0になるまで繰り返します。

ユークリッドの互除法の時間計算量はどれくらいですか?

O(log min(a, b)) です。ステップ数は桁数に比例するため、非常に大きな数であっても極めて高速に計算できます。

なぜ gcd(a, b) = gcd(b, a mod b) が成り立つのですか?

a と b の公約数はすべて a mod b も割り切れます(その逆も同様です)。そのため、この置き換えを行っても公約数の集合、つまり最大公約数は変わりません。

GCDは何に使われますか?

分数の約分、モジュラー算術、拡張ユークリッドの互除法(モジュラー逆数、RSA)、そして lcm(a,b) = a·b / gcd(a,b) の式による最小公倍数の計算などに使われます。