기본·수학

최대공약수·최소공배수

GCD·LCM을 즉시 산출

최대공약수·최소공배수 계산기란?

최대공약수(GCD)는 두 개 이상의 정수를 동시에 나누어 떨어지게 하는 가장 큰 수이고, 최소공배수(LCM)는 그 정수들의 공통 배수 중 가장 작은 수입니다. 이 계산기는 콤마로 구분한 정수 여러 개를 받아 GCD와 LCM을 즉시 계산합니다.

사용 방법

계산할 양의 정수를 콤마(,)로 구분해 2개 이상 입력한 뒤 계산하기를 누릅니다. 예: 12, 18, 24. 소수·음수·0은 입력할 수 없습니다.

공식·계산 과정

유클리드 호제법: GCD(a, b) = GCD(b, a mod b), b가 0이 될 때까지 반복. LCM(a, b) = (a × b) ÷ GCD(a, b). 숫자가 3개 이상이면 두 개씩 순서대로 누적 계산합니다.

예시
입력GCDLCM
12, 18636
12, 18, 24672
타일 깔기(GCD)와 버스 배차 만남(LCM)으로 보는 실생활 계산

가로 360cm, 세로 240cm인 방을 자투리 조각 없이 정사각형 타일로 완전히 채우고 싶다면, 쓸 수 있는 가장 큰 정사각형 타일의 한 변은 두 길이의 최대공약수와 같아야 합니다. GCD(360, 240)=120이므로 한 변 120cm 타일을 쓰면 가로에 360÷120=3장, 세로에 240÷120=2장, 총 6장으로 빈틈없이 시공됩니다. 만약 임의로 100cm 타일을 골랐다면 360과 240 모두 100으로 나누어떨어지지 않아 가장자리에 자투리가 생깁니다.

버스 배차에서는 반대로 LCM이 쓰입니다. 12분 간격으로 오는 A노선 버스와 18분 간격으로 오는 B노선 버스가 오전 9시에 동시에 출발했다면, 두 버스가 다시 동시에 출발하는 시각은 두 배차 간격의 최소공배수만큼 지난 뒤입니다. LCM(12, 18)=36이므로 36분 뒤인 9시 36분에 두 버스가 다시 함께 출발합니다. 타일은 '더 이상 못 쪼개는 공통 단위(GCD)'를, 배차는 '다시 만나는 공통 주기(LCM)'를 구한다는 점에서 같은 두 정수 문제의 정반대 쓰임입니다.

유클리드 호제법, 한 줄로 이해하기

유클리드 호제법은 큰 수를 작은 수로 나눈 나머지로 계속 바꿔가며 나머지가 0이 될 때까지 반복하는 방법입니다. GCD(48, 18)을 예로 들면: 48 mod 18 = 12 → (18, 12)로 교체, 18 mod 12 = 6 → (12, 6)으로 교체, 12 mod 6 = 0이 되는 순간 직전의 나머지 6이 최대공약수입니다. 이 계산기도 내부적으로 같은 방식을 사용해 아무리 큰 수라도 몇 단계 만에 GCD를 찾아냅니다.

What is the GCD & LCM Calculator?

The greatest common divisor (GCD) is the largest number that evenly divides two or more integers, while the least common multiple (LCM) is the smallest number that is a multiple of all of them. This tool accepts comma-separated integers and computes both instantly.

How to use it

Enter two or more positive integers separated by commas, e.g. 12, 18, 24, then press Calculate. Decimals, negatives, and zero are not accepted.

Formula & process

Euclidean algorithm: GCD(a, b) = GCD(b, a mod b), repeated until b is 0. LCM(a, b) = (a × b) ÷ GCD(a, b). For three or more numbers, the result accumulates pairwise in order.

Examples
InputGCDLCM
12, 18636
12, 18, 24672
Tiling a floor (GCD) and buses meeting up (LCM) — two everyday calculations

To tile a 360cm × 240cm room completely with square tiles and no leftover scraps, the largest usable tile side must equal the greatest common divisor of the two lengths. GCD(360, 240)=120, so a 120cm tile gives 360÷120=3 tiles across and 240÷120=2 tiles down — 6 tiles total, with no gaps. Pick an arbitrary 100cm tile instead, and neither 360 nor 240 divides evenly by 100, leaving scrap pieces at the edges.

Bus schedules use the LCM the opposite way. If a Route A bus arrives every 12 minutes and a Route B bus every 18 minutes, and both depart together at 9:00 AM, they next depart together after the least common multiple of the two intervals. LCM(12, 18)=36, so they meet again 36 minutes later, at 9:36 AM. Tiling finds the "largest shared unit that still fits" (GCD), while bus schedules find the "shared cycle where both realign" (LCM) — opposite uses of the same pair of integers.

The Euclidean algorithm in one line

The Euclidean algorithm repeatedly replaces the larger number with the remainder of dividing it by the smaller, until the remainder reaches 0. For GCD(48, 18): 48 mod 18 = 12 → continue with (18, 12); 18 mod 12 = 6 → continue with (12, 6); 12 mod 6 = 0, so the last nonzero remainder, 6, is the GCD. This calculator uses the exact same method internally, finding the GCD of even very large numbers in just a few steps.

최대공약수(GCD)는 어떻게 계산되나요?
이 계산기는 유클리드 호제법을 사용합니다. 두 수 a, b가 있을 때 a를 b로 나눈 나머지를 구해 b와 나머지의 쌍으로 반복하며, 나머지가 0이 되었을 때의 b가 최대공약수입니다. 숫자가 3개 이상이면 앞에서부터 두 개씩 GCD를 구해 누적합니다.
최소공배수(LCM)는 어떻게 계산되나요?
두 수 a, b의 최소공배수는 (a×b) ÷ GCD(a,b) 공식으로 계산합니다. 숫자가 여러 개인 경우 앞의 두 값의 LCM을 구한 뒤, 그 결과와 다음 값의 LCM을 순서대로 누적해 계산합니다.
음수나 0을 입력해도 되나요?
이 계산기는 1 이상의 양의 정수만 지원합니다. 0이나 음수, 소수를 입력하면 오류로 표시되며, 콤마로 구분해 2개 이상의 정수를 입력해야 계산이 가능합니다.
타일 바닥 시공에서 GCD는 어떻게 쓰이나요?
가로 360cm, 세로 240cm인 방을 자투리 없이 정사각형 타일로 채우려면, 가능한 가장 큰 정사각형 타일의 한 변이 두 길이의 최대공약수와 같아야 합니다. GCD(360, 240)=120이므로 한 변 120cm인 타일을 쓰면 가로 3장, 세로 2장으로 빈틈없이 채울 수 있습니다.
배차 간격이 다른 두 버스가 같이 출발하는 시간은 LCM으로 어떻게 구하나요?
12분 간격 버스와 18분 간격 버스가 오전 9시에 동시 출발했다면, 다음에 다시 같이 출발하는 시간은 두 배차 간격의 최소공배수 뒤입니다. LCM(12, 18)=36이므로 36분 뒤인 9시 36분에 두 버스가 다시 동시에 출발합니다.
How is the GCD calculated?
This tool uses the Euclidean algorithm: for two numbers a and b, it repeatedly replaces (a, b) with (b, a mod b) until the remainder is 0 — the last nonzero b is the GCD. For three or more numbers, GCD is accumulated pairwise from left to right.
How is the LCM calculated?
The LCM of two numbers a and b is (a×b) ÷ GCD(a,b). For multiple numbers, the LCM of the first two is computed, then combined with each subsequent value in order.
Can I enter negative numbers or zero?
This tool only supports positive integers of 1 or greater. Zero, negative numbers, or decimals will show an error, and you must enter two or more comma-separated integers.
How is GCD used when tiling a floor?
To tile a 360cm × 240cm room completely with square tiles and no scraps, the largest usable tile side must equal the GCD of the two lengths. GCD(360, 240)=120, so a 120cm tile fits 3 across and 2 down with no gaps.
How do I use LCM to find when two buses with different intervals depart together again?
If a bus every 12 minutes and a bus every 18 minutes depart together at 9:00 AM, they next depart together after the LCM of the two intervals. LCM(12, 18)=36, so they align again 36 minutes later, at 9:36 AM.