Check If Two Numbers Are Coprime Using A Calculator






Coprime Calculator: Check If Two Numbers Are Relatively Prime


Coprime Calculator

An online tool to check if two integers are coprime, also known as relatively prime.

Check for Coprime Numbers

Enter two positive integers to determine if they are coprime. The results will update automatically.




Greatest Common Divisor (GCD)
Product (A * B)
Least Common Multiple (LCM)

Formula Used: Two numbers, A and B, are coprime if their Greatest Common Divisor (GCD) is 1. The GCD is found using the Euclidean Algorithm. The Least Common Multiple (LCM) is calculated as (A * B) / GCD(A, B).

Step-by-step Euclidean Algorithm
Step Larger Value (a) Smaller Value (b) a mod b (Remainder)
Visual Comparison of Input Numbers Number Comparison A B

Dynamic chart comparing the magnitude of the two numbers.

What is a Coprime Calculator?

A coprime calculator is a specialized tool designed to determine if two integers are coprime. Two numbers are considered coprime, relatively prime, or mutually prime if their only common positive divisor is the number 1. This means they share no common factors other than 1. For example, the numbers 8 and 15 are coprime. The factors of 8 are {1, 2, 4, 8} and the factors of 15 are {1, 3, 5, 15}. The only factor they share is 1, so they are coprime, even though neither 8 nor 15 is a prime number.

This calculator is useful for students, mathematicians, and programmers who need a quick and reliable way to check for coprimality. Unlike a general calculator, a coprime calculator automates the process of finding the greatest common divisor (GCD) to provide an instant answer. Anyone studying number theory, cryptography, or even music theory might find this tool indispensable. A common misconception is that at least one of the numbers must be prime for them to be coprime, which, as the example of 8 and 15 shows, is incorrect.

Coprime Calculator Formula and Mathematical Explanation

The core principle behind the coprime calculator is the concept of the Greatest Common Divisor (GCD). Two integers, ‘a’ and ‘b’, are coprime if and only if GCD(a, b) = 1. The most efficient method for finding the GCD is the Euclidean Algorithm. This ancient algorithm is one of the oldest in common use and is based on the principle that the greatest common divisor of two numbers does not change if the larger number is replaced by its difference with the smaller number, or more efficiently, by its remainder after division by the smaller number.

The algorithm proceeds as follows:

  1. Given two numbers, ‘a’ and ‘b’, where a > b.
  2. Divide ‘a’ by ‘b’ and find the remainder, ‘r’. So, a = b*q + r (where q is the quotient).
  3. Replace ‘a’ with ‘b’ and ‘b’ with ‘r’.
  4. Repeat the process until the remainder ‘r’ becomes 0.
  5. The GCD is the last non-zero remainder.

If the final GCD result from this algorithm is 1, the numbers are coprime. Our coprime calculator performs these steps instantly.

Variables Used in Coprime Calculation
Variable Meaning Unit Typical Range
A The first integer being tested. Integer Positive integers (e.g., 1, 2, 3…)
B The second integer being tested. Integer Positive integers (e.g., 1, 2, 3…)
GCD(A, B) The Greatest Common Divisor of A and B. Integer A positive integer ≥ 1.

Practical Examples (Real-World Use Cases)

Example 1: Coprime Numbers

  • Inputs: Number A = 21, Number B = 55
  • Calculation:
    • GCD(55, 21): 55 = 2 * 21 + 13
    • GCD(21, 13): 21 = 1 * 13 + 8
    • GCD(13, 8): 13 = 1 * 8 + 5
    • GCD(8, 5): 8 = 1 * 5 + 3
    • GCD(5, 3): 5 = 1 * 3 + 2
    • GCD(3, 2): 3 = 1 * 2 + 1
    • GCD(2, 1): 2 = 2 * 1 + 0
  • Outputs:
    • Primary Result: Coprime (The numbers are coprime).
    • Intermediate Value (GCD): 1.
  • Interpretation: Since the greatest common divisor is 1, the numbers 21 and 55 are relatively prime. This is confirmed by the coprime calculator.

Example 2: Non-Coprime Numbers

  • Inputs: Number A = 48, Number B = 18
  • Calculation:
    • GCD(48, 18): 48 = 2 * 18 + 12
    • GCD(18, 12): 18 = 1 * 12 + 6
    • GCD(12, 6): 12 = 2 * 6 + 0
  • Outputs:
    • Primary Result: Not Coprime (The numbers are not coprime).
    • Intermediate Value (GCD): 6.
  • Interpretation: The greatest common divisor is 6 (which is greater than 1), so 48 and 18 are not coprime. They share common factors other than 1, including 2, 3, and 6. The coprime calculator correctly identifies this relationship.

How to Use This Coprime Calculator

Using this coprime calculator is straightforward and efficient. Follow these simple steps to get an instant and accurate analysis of any two integers:

  1. Enter the First Number: In the input field labeled “First Number (A)”, type the first positive integer you wish to check.
  2. Enter the Second Number: In the input field labeled “Second Number (B)”, type the second positive integer.
  3. Read the Results Instantly: As you type, the calculator automatically updates. The primary result will clearly state whether the numbers are “Coprime” or “Not Coprime”.
  4. Analyze the Intermediate Values: Below the main result, the calculator shows the Greatest Common Divisor (GCD), the product of the two numbers, and their Least Common Multiple (LCM).
  5. Review the Step-by-Step Table: For educational purposes, a table showing the full Euclidean Algorithm process is generated, allowing you to follow the logic of the GCD calculation.
  6. Visualize with the Chart: A simple bar chart provides a visual representation of the magnitude of the two numbers.
  7. Use the Buttons: Click “Reset” to clear the fields and return to the default values. Click “Copy Results” to copy a summary of the inputs and results to your clipboard.

Key Factors That Affect Coprime Results

While the concept is binary—two numbers either are or are not coprime—the underlying properties of the numbers dictate the result. Understanding these factors is key to understanding number theory. Using a coprime calculator helps verify these properties quickly.

  • Prime Factorization: This is the most fundamental factor. Two numbers are coprime if and only if they share no common prime factors. For example, 14 (2 * 7) and 15 (3 * 5) share no prime factors, so they are coprime.
  • Presence of Even Numbers: Two distinct even numbers can never be coprime because they will always share a common factor of 2.
  • Consecutive Integers: Any two consecutive integers (e.g., 14 and 15) are always coprime. Their difference is 1, so they can’t share any factor larger than 1.
  • Prime Numbers: Any two distinct prime numbers are always coprime. Since their only factors are 1 and themselves, their only common factor is 1. For example, 17 and 23 are coprime.
  • The Number 1: The number 1 is coprime to every integer. This is because GCD(n, 1) is always 1 for any integer n.
  • Relationship to LCM: The Least Common Multiple (LCM) of two coprime numbers is simply their product. For non-coprime numbers, LCM(a, b) = (a * b) / GCD(a, b). This relationship is a direct consequence of their coprimality.

Frequently Asked Questions (FAQ)

1. What are coprime numbers?

Coprime numbers (also called relatively prime numbers) are two integers that have no common factors other than 1. This means their Greatest Common Divisor (GCD) is 1. This coprime calculator is the fastest way to check this.

2. Do numbers have to be prime to be coprime?

No. This is a common misconception. For example, 9 and 25 are not prime numbers, but they are coprime because their only common factor is 1. The factors of 9 are {1, 3, 9} and the factors of 25 are {1, 5, 25}.

3. Are any two prime numbers coprime?

Yes, any two distinct prime numbers are always coprime. A prime number’s only factors are 1 and itself, so two different prime numbers can only share the factor 1.

4. Are two consecutive numbers always coprime?

Yes. Any two consecutive integers, like 15 and 16, will always be coprime. This is because any common divisor would have to divide their difference, which is 1. The only positive integer that divides 1 is 1 itself.

5. Can two even numbers be coprime?

No, two distinct even numbers cannot be coprime. They will always share a common factor of 2, so their GCD will be at least 2.

6. What is the relationship between GCD and coprime?

The relationship is definitional. Two numbers ‘a’ and ‘b’ are coprime if and only if their Greatest Common Divisor, GCD(a, b), is equal to 1. Our coprime calculator finds the GCD to determine the result.

7. Where is the concept of coprime numbers used?

Coprime numbers are fundamental in many areas of mathematics and computer science. They are crucial in cryptography, particularly in the RSA algorithm. They are also used in machine design to create uniform gear wear and in simplifying fractions.

8. Is 1 coprime to every other number?

Yes. The number 1 is coprime to every integer because the greatest common divisor of any integer ‘n’ and 1 is always 1 (i.e., GCD(n, 1) = 1).

© 2026 Your Website. All rights reserved. This calculator is for informational purposes only.


Leave a Reply

Your email address will not be published. Required fields are marked *