LCM & GCD Calculator

Calculate the Least Common Multiple (LCM) and Greatest Common Divisor (GCD) of any set of numbers with our free online calculator. Get step-by-step solutions and understand the mathematical concepts behind these fundamental number theory operations.

LCM & GCD Calculator

Calculate Least Common Multiple (LCM) and Greatest Common Divisor (GCD) with step-by-step solutions

Enter Numbers

Calculation Type:
Both LCM and GCD
0 number(s) entered

About LCM & GCD

• GCD: Largest number that divides all given numbers evenly

• LCM: Smallest number that is a multiple of all given numbers

• Relationship: LCM(a,b) × GCD(a,b) = |a × b|

• Euclidean Algorithm: Efficient method for finding GCD

Common Examples

12, 18
Common factors and multiples
GCD: 6
LCM: 36
8, 12, 16
Multiple numbers
GCD: 4
LCM: 48
15, 25
Prime factorization
GCD: 5
LCM: 75
7, 13
Coprime numbers
GCD: 1
LCM: 91

Real-World Applications

• Simplifying fractions
• Finding common denominators
• Scheduling problems
• Cryptography algorithms
• Music theory (intervals)
• Engineering calculations

Understanding LCM and GCD

Greatest Common Divisor (GCD)

The Greatest Common Divisor, also known as the Greatest Common Factor (GCF), is the largest positive integer that divides each of the given integers without leaving a remainder.

Example:

For numbers 48 and 18:
• Factors of 48: 1, 2, 3, 4, 6, 8, 12, 16, 24, 48
• Factors of 18: 1, 2, 3, 6, 9, 18
• Common factors: 1, 2, 3, 6
• GCD = 6

Least Common Multiple (LCM)

The Least Common Multiple is the smallest positive integer that is divisible by each of the given integers.

Example:

For numbers 12 and 18:
• Multiples of 12: 12, 24, 36, 48, 60, 72...
• Multiples of 18: 18, 36, 54, 72, 90...
• Common multiples: 36, 72...
• LCM = 36

Key Mathematical Relationship

For any two positive integers a and b, there's an important relationship between their LCM and GCD:

LCM(a,b) × GCD(a,b) = |a × b|

This relationship allows us to find one value when we know the other.

How to Use the Calculator

1

Choose Calculation Type

Select whether you want to calculate both LCM and GCD, only LCM, or only GCD. This helps focus the calculation on what you need most.

2

Enter Your Numbers

Input at least 2 positive integers. You can add more numbers if needed. The calculator supports any number of inputs for comprehensive calculations.

3

Get Results

Click calculate to see your results. The calculator provides both the numerical answers and detailed step-by-step explanations of how the calculations were performed.

Applications in Real Life

Mathematics Education

  • • Simplifying fractions to lowest terms
  • • Finding common denominators for addition
  • • Understanding number theory concepts
  • • Solving word problems involving multiples

Engineering & Science

  • • Gear ratios and mechanical systems
  • • Electrical circuit timing
  • • Chemical reaction stoichiometry
  • • Signal processing algorithms

Computer Science

  • • Cryptography algorithms
  • • Hash function design
  • • Memory allocation optimization
  • • Algorithm complexity analysis

Everyday Life

  • • Scheduling recurring events
  • • Planning synchronized activities
  • • Music theory and intervals
  • • Construction and measurement

Mathematical Algorithms Used

Euclidean Algorithm for GCD

The calculator uses the efficient Euclidean algorithm, which is based on the principle that the GCD of two numbers also divides their difference.

function gcd(a, b):
while b ≠ 0:
temp = b
b = a mod b
a = temp
return a

LCM Calculation

LCM is calculated using the relationship with GCD, which is more efficient than finding all multiples.

function lcm(a, b):
return |a × b| / gcd(a, b)

Multiple Number Handling

For more than two numbers, the calculator applies the algorithms iteratively, calculating pairwise and building up to the final result.