Relatively Prime Calculator

Relatively Prime Calculator

Quick Examples:
Source: Mathematics Principles / Investopedia

Relatively Prime Calculator & Coprime Checker

Welcome to your go-to resource for number theory. The concept of coprimality is vital. It connects computer security, engineering, and music. It seems simple: do two numbers share a divisor? But the answer changes how we secure the internet and build machines.

This guide explains the “why” behind the math. We go beyond simple “yes or no” answers. We look at the algorithms and logic used by experts. This tool is part of the My Online Calculators suite. We design our tools to educate, not just compute.

By the end, you will know how to determine if two numbers are coprime. You will also understand Euler’s Totient function and the Euclidean Algorithm.

What is the Relatively Prime Calculator?

The relatively prime calculator analyzes two or more integers. It looks for common factors. Standard calculators add or multiply. This tool checks the properties of the numbers.

Two integers are relatively prime (or coprime) if their only common divisor is 1. They have no other shared building blocks. This tool automates the math. It finds the Greatest Common Divisor (GCD) instantly.

How to Use Our Coprime Checker Online

We designed this coprime checker online for speed and ease. It works for students and professionals. Follow these steps:

  1. Find the Inputs: Look for “Number A” and “Number B” at the top.
  2. Enter Integers: Type the two whole numbers you want to check.
    • Example: Try 14 and 15. They are not prime numbers, but they are coprime to each other.
  3. Add More Numbers: Do you have a set of three? Click “Add Number” to check more digits.
  4. Click Calculate: Hit the blue button.
  5. Read the Result:
    • Status: It will say “COPRIME” (Green) or “NOT COPRIME” (Red).
    • GCD: It shows the Greatest Common Factor. If the GCD is 1, they are coprime.
    • Factors: You will see the factors listed. This proves the result.

Coprime Formula Explained

How does the math work? The definition relies on the greatest common divisor and coprimality.

The Rule:
Integers a and b are relatively prime if:
GCD(a, b) = 1

Every number is made of prime factors. These are like atoms. To check for coprimality, we compare the atoms. You can visualize this using a prime factorization tool.

Example 1: 12 and 35

  • Factors of 12: {1, 2, 3, 4, 6, 12}
  • Factors of 35: {1, 5, 7, 35}

The only number on both lists is 1. They are coprime.

Example 2: 12 and 15

  • Factors of 12: {1, 2, 3, 6, 12}
  • Factors of 15: {1, 3, 5, 15}

They share 1 and 3. The GCD is 3. They are not relatively prime.

Everything About Coprime Numbers

Most articles stop at the basics. We will go deeper. This section covers the expert concepts you need to know.

1. Mutually Prime Numbers Examples

When you check three numbers, it gets tricky. There is a difference between “Mutually Prime” and “Pairwise Prime.”

Mutually Prime (Set-wise): The numbers share no common factor across all three.

  • Set: {6, 10, 15}
  • 6 is divisible by 2 and 3.
  • 10 is divisible by 2 and 5.
  • 15 is divisible by 3 and 5.

No single number divides all three. They are mutually prime.

Pairwise Prime: Every pair must be coprime. In the set above, 6 and 10 share a 2. They fail this test. Pairwise prime is a much stricter standard.

2. Relatively Prime vs Prime Numbers

This is a common mistake. “Prime” applies to one number. “Relatively Prime” applies to the relationship between two numbers.

Can composite numbers be coprime?
Yes. Look at 25 and 26. Neither is prime. 25 is $5 \times 5$. 26 is $2 \times 13$. They share no factors. They are relatively prime.

3. Euclidean Algorithm for Coprime Numbers

Computers do not list factors for huge numbers. It takes too long. Instead, they use the Euclidean Algorithm for coprime numbers. It is fast and efficient.

The Logic: If a number divides both A and B, it also divides (A – B).

  1. Divide A by B. Get the remainder.
  2. Swap the numbers. Divide B by the remainder.
  3. Repeat until the remainder is 0.
  4. The last non-zero remainder is the GCD.

If that final result is 1, your numbers are coprime.

4. Euler’s Totient Function Explanation

In cryptography, we count coprimes. We use Euler’s Totient Function, written as $\phi(n)$. It counts how many integers below $n$ are coprime to $n$.

For a prime number $p$, the answer is easy: $p – 1$. For two primes multiplied together, it helps create encryption keys.

Real-World Applications

Why does this matter? It is not just for homework. It builds our world.

RSA Cryptography Relatively Prime Numbers

RSA cryptography relatively prime numbers protect your data. When you create a digital key, you pick a public exponent. This number must be relatively prime to the totient of your modulus. If it isn’t, the math breaks. You cannot decrypt the message. Coprimality is the gatekeeper of security.

Coprimality in Gear Ratios and Music Theory

Engineers use this for gears. Imagine a 13-tooth gear and a 41-tooth gear. They are coprime. This means every tooth on the small gear hits every tooth on the big gear before repeating. This spreads out wear and tear. It prevents damage.

In music, coprimality in gear ratios and music theory creates polyrhythms. A 5:4 rhythm is coprime. The beats do not align for a long time. This creates tension and complex patterns in jazz and classical music.

Frequently Asked Questions

How do I determine if two numbers are coprime quickly?

Use heuristics. Consecutive numbers (like 20 and 21) are always coprime. Two different prime numbers are always coprime.

Is 1 relatively prime to everything?

Yes. The GCD of 1 and any number is 1. Therefore, 1 is coprime to all integers.

Can two even numbers be coprime?

No. Even numbers are both divisible by 2. Their GCD is at least 2. They cannot be coprime.

What are mutually prime numbers examples?

A set like {3, 7, 11} is mutually prime. Actually, this set is also pairwise prime because no two numbers share a factor.

Ready to check your numbers? Scroll to the top and use the Relatively Prime Calculator now!

Try More Calculators

People also ask

Two integers are relatively prime (also called coprime) if their greatest common divisor (GCD) is 1. In plain terms, they don’t share any factor other than 1.

Example: 8 and 15 are relatively prime because 8 has factors 1, 2, 4, 8 and 15 has factors 1, 3, 5, 15, so there’s no overlap besides 1.

Most calculators use one of these methods:

  • GCD (Euclidean algorithm): It repeatedly divides and takes remainders until it reaches 0. The last non-zero remainder is the GCD. If that value is 1, your numbers are coprime.
  • Prime factorization: It breaks each number into prime factors and checks whether the lists share any primes. If they share none, the numbers are coprime.

Both methods agree on the result, but the Euclidean algorithm is usually faster for large numbers.

Yes. Coprime doesn’t mean prime. It only means the two numbers don’t share factors.

Example: 14 and 25 are relatively prime.

Yes. Any two consecutive integers are always coprime, because no number greater than 1 can divide both.

Example: 200 and 201 are relatively prime.

When you enter more than two numbers, calculators may show two related ideas:

  • Coprime as a set: The whole set has GCD 1 (all numbers together share no common factor).
  • Pairwise coprime: Every pair in the set is coprime.

A set can have GCD 1 without being pairwise coprime, so it’s worth checking what the calculator is reporting.

If gcd(a, b) = 1, then their least common multiple is simple:

lcm(a, b) = a × b

That’s a handy shortcut when you’re working with schedules, repeating cycles, or fraction work.

A fraction is in lowest terms when the numerator and denominator are relatively prime.

Yes. A quick way is to choose a number that doesn’t share any prime factors with your starting number.

Most calculators treat this in a standard math way:

  • Negative numbers: Usually fine, since gcd(-a, b) = gcd(a, b). The sign doesn’t change coprime status.
  • Zero: gcd(a, 0) = |a|, so a and 0 are relatively prime only when |a| = 1 (that is, a = 1 or a = -1).