Relatively Prime Calculator

Created by Krishna Nelaturu
Reviewed by Anna Szczepanek, PhD and Steven Wooding
Last updated: Mar 27, 2023

Our relatively prime calculator will help you determine whether two numbers are relatively prime. Don't fret if this is your first time hearing the terms "relatively prime" or "coprime numbers." In the following article, we shall go through the fundamentals on this topic, including:

  • Definition of relatively prime numbers.
  • How to check whether two numbers are coprime?
  • How to calculate relatively prime numbers?
  • Coprimes in a set of numbers.

You would benefit from learning about prime numbers before learning about coprime numbers. Our prime number calculator will help.

Definition of relatively prime numbers

Relatively prime numbers are a pair of natural numbers with only 1 as the common factor between them. This means that any number that can divide one number cannot divide the other. We also call such pairs coprime or mutually prime numbers.

If a and b are coprime, we can say that:

  • a is prime to b; or
  • a is coprime with b.

Relatively prime numbers need not be prime numbers! For example, consider the numbers 14 and 15. Both of them are composite numbers:

  • 14=2×714 = 2 \times 7. Factors:1,2,7,14\rm{Factors: 1, 2, 7, 14}.
  • 15=3×515 = 3 \times 5. Factors:1,3,5,15\rm{Factors: 1, 3, 5, 15}.

But the only common factor between 14 and 15 is 1. Hence, 14 is prime to 15.

Need help with prime factorization? Use our very popular prime factorization calculator!

🙋 Since 1 is the only common factor of coprime numbers, their greatest common factor is 1. Learn more about the GCF of two numbers with our GCF calculator.

How to check whether two numbers are relatively prime

To check whether two given numbers are coprime, follow these steps:

  1. Prime factorize the two numbers.
  2. Find any common factors between the two.
  3. The numbers are coprime if there are no prime common factors between the two (i.e., if 1 is the only common factor). If there are other common factors, then the numbers are not coprime.

For example, look at the numbers 14 and 27:

  • 12:=2×712:= 2 \times 7.
  • 27:=3×3×327:= 3 \times 3 \times 3.

Since there are no common prime factors, they are coprime. Thus we say 12 is prime to 27.

Now, take the numbers 18 and 27:

  • 18:=2×3×318:= 2 \times 3 \times 3.
  • 27:=3×3×327:= 3 \times 3 \times 3.

Since 3 is a common prime factor between 18 and 27, they are not coprime.

Let's learn how to calculate coprime numbers for a given number in the next section.

How do you calculate relatively prime numbers?

To calculate a relatively prime number for a given number a, follow these steps:

  1. Prime factorize a to get all of its prime factors.
  2. Find any prime number that is not a prime factor of a. That prime number will be a relatively prime with a.
  3. Alternatively, find any natural number that does not share a common prime factor with a. That number will be relatively prime with a.

For example, consider the number 45. Its prime factors are: 45=3×3×545 = 3 \times 3 \times 5.

  • Since 22 is a prime number that is not a prime factor of 45, we can conclude that 2 and 45 are relatively prime.

  • We could also find other natural numbers like 14=2×714= 2 \times 7 that do not share any common prime factors with 45. Thus, 14 and 45 are relatively prime.

Coprimes in sets

We say that a set of integers A={a1,a2,a3,...,an}A = \{a_1, a_2,a_3,...,a_n\} is relatively prime or setwise coprime if their greatest common factor is 1. For example, the set of numbers {4, 6, 21} is setwise coprime, since the GCF(4, 6, 21) = 1.

If every pair of integers in the set are coprime, then we say the set is pairwise coprime. In the above example, the set {4, 6, 21} is setwise coprime, but not pairwise coprime, since the pair (4,6) is not coprime. Now consider the set {4, 7, 27}. In this set, every pair of integers are coprime too! Hence, the set {4, 7, 27} is pairwise coprime!

Using our relatively prime calculator

Our coprime calculator is easy to use:

  • Want to determine whether two numbers are coprime or not?

    1. In the Check for field, choose the option a pair of numbers.

    2. Enter the numbers in the fields labeled #1 and #2, and our calculator will give you the result immediately.

  • Do you want to know whether a set of numbers are setwise coprime?

    1. In the Check for field, choose the option a set of numbers.

    2. Enter the numbers in the fields labeled #1, #2, etc. You can enter up to ten numbers!

    3. Once you input three or more numbers, the calculator will tell you whether the set of numbers is relatively prime, pairwise coprime, or not coprime at all.


Are the numbers 42 and 75 relatively prime?

The numbers 42 and 75 are NOT relatively prime. To figure this out yourself, follow these steps:

  1. Factorize 42 to get its prime factors:

    42 = 2 × 3 × 7

  2. Factorize 75 for its prime factors:

    75 = 3 × 5 × 5

  3. Notice that 42 and 75 share 3 as a common prime factor. Hence, they cannot be coprime.

  4. You can verify your result with an online relatively prime calculator.

Can two even numbers be coprime?

No, since all even numbers share 2 as their common factor, they cannot be relatively prime. At least one number has to be odd for a pair (or a set) of numbers to be coprime.

Is 1 relatively prime to any number?

Yes, 1 is relatively prime to every number. This is because the only common factor between 1 and any other number is 1, as required in the definition of relatively prime numbers.

Krishna Nelaturu
Check for..
a pair of numbers.
Check out 71 similar arithmetic calculators ➗
Absolute changeAbsolute valueAdding and subtracting fractions… 68 more
People also viewed…

Lost socks

Socks Loss Index estimates the chance of losing a sock in the laundry.

Sine function

The sine function calculator will tell you everything you need to know about this fundamental trigonometric function.

Steps to calories

Steps to calories calculator helps you to estimate the total amount to calories burned while walking.

Tetrahedron volume

Estimate properties of your tetrahedron shape using the tetrahedron volume calculator.
Copyright by Omni Calculator sp. z o.o.
Privacy policy & cookies
main background