Skip to main content
Skip to calculator
Advertisement

Last updated: July 31, 2026

GCD Calculator

Helpful
Not helpful
Save as image
Share
Embed
Cite
Write feedback

Formula

gcd via Euclidean algorithm; lcm = |a×b| / gcd

Where:

  • a=First Integer
  • b=Second Integer
Greatest Common Divisor (Euclidean Algorithm)Repeated division steps 18 mod 12 = 6, then 12 mod 6 = 0, giving a GCD of 6.gcd(18, 12)gcd(12, 6)gcd(6, 0)GCD = 6
The Euclidean algorithm repeatedly replaces the larger number with the remainder until it reaches 0.

Worked Examples

Standard pair

Find gcd and lcm for 84 and 30.

  1. 1Euclidean steps give gcd=6
  2. 2Compute lcm=|84×30|/6
  3. 3lcm=420
Final Answer: gcd=6, lcm=420

One value zero

Find gcd and lcm for 0 and 45.

  1. 1gcd(0,45)=45
  2. 2LCM with zero is 0
  3. 3Return both values
Final Answer: gcd=45, lcm=0

Negative integers

Find gcd and lcm for -27 and 36.

  1. 1Use absolute values in gcd steps
  2. 2gcd=9
  3. 3lcm=|(-27×36)|/9=108
Final Answer: gcd=9, lcm=108

Introduction

The GCD measures common divisibility, while LCM finds the smallest shared multiple for integer pair analysis.

Formula and Method

GCD Calculator applies gcd via Euclidean algorithm; lcm = |a×b| / gcd and returns deterministic outputs from validated inputs.

  • Validate each required input

  • Apply the stated formula

  • Round numeric outputs where needed

  • Return safe defaults when validation fails

Input Fields

Use these keys exactly as defined in calculation.ts.

  1. 1

    a: First Integer

  2. 2

    b: Second Integer

Output Fields

These values map directly to calculation.ts return keys.

  1. 1

    gcd: Largest integer dividing both values

  2. 2

    lcm: Smallest positive multiple shared by both values

Validation Rules

Inputs must be integers and not both zero.

  • Finite numeric values are required

  • Domain restrictions are enforced before solving

  • Invalid input returns default-safe outputs

  • Check examples to confirm expected behavior

How to Use This Calculator

Enter inputs, run the calculation, and read the primary output first.

  • Enter all required values

  • Click calculate

  • Review primary output first

  • Use supporting outputs for interpretation

Practical Uses

This calculator is useful for study, verification, and fast applied math checks.

  • Fraction simplification

  • Scheduling and cyclic events

  • Number theory learning

  • Algorithmic preprocessing

FAQs

What does the GCD Calculator compute?

It computes Greatest Common Divisor and supporting outputs from your inputs.

Which inputs are required?

Required inputs are: First Integer, Second Integer.

How are invalid inputs handled?

When validation fails, the calculator returns safe default values and does not attempt invalid math.

Are results rounded?

Yes. Numeric outputs are rounded inside calculation.ts (typically to 6 decimal places).

Can I use negative or decimal values?

Integer inputs are required; negative integers are supported via absolute-value logic.

How should I verify my answer?

Use the worked examples and compare each output key with your manual steps.