How the Relatively Prime Calculator works
Two integers a and b are relatively prime (also called coprime) when their greatest common divisor is 1: gcd(a, b) = 1. This has nothing to do with whether a or b are prime themselves — it only means they share no common positive factor larger than 1. This calculator computes gcd(a, b) with the Euclidean algorithm, reports whether the pair is relatively prime, and also derives the least common multiple (LCM) and the reduced ratio a : b.
The Euclidean algorithm
The fastest way to find gcd(a, b) is the Euclidean algorithm: divide the larger number by the smaller one and keep the remainder, then repeat with (smaller number, remainder) until the remainder hits 0 — the last nonzero remainder is the GCD. For example, gcd(14, 9): 14 mod 9 = 5, then 9 mod 5 = 4, then 5 mod 4 = 1, then 4 mod 1 = 0, so gcd(14, 9) = 1, which means 14 and 9 are relatively prime. The calculator uses negative-safe absolute values, so gcd(-14, 9) still returns 1.
Determining if two numbers are relatively prime
Once gcd(a, b) is known, the relatively-prime check is simple: if the GCD equals 1, the numbers are relatively prime; any GCD greater than 1 means they share that value as a common factor and are not relatively prime. From the same GCD, the calculator derives two useful bonus values: the LCM, using lcm(a, b) = |a × b| / gcd(a, b), and the fully reduced ratio a/gcd(a,b) : b/gcd(a,b), which is exactly how you would simplify the fraction a/b to lowest terms.
Common mistakes
- Confusing "relatively prime" with "prime": 14 and 9 are relatively prime even though neither is a prime number — relatively prime describes a pair, not a single number's primality.
- Assuming shared even/odd parity matters: two odd numbers can still share a large common factor (15 and 9 both share 3), and one even plus one odd number can still be relatively prime (8 and 9).
- Forgetting the zero case: gcd(0, n) = |n|, so 0 is relatively prime only to 1 or -1, and gcd(0, 0) is undefined.
Real-world applications
- Simplifying fractions to lowest terms uses the same GCD computed here — divide numerator and denominator by gcd(a, b).
- Cryptography (including RSA key generation) relies on choosing exponents that are relatively prime to a modulus.
- Gear and pulley design uses coprime tooth counts so that two meshing gears don't repeatedly pair the same teeth, spreading out wear evenly.
- Scheduling and cycle problems (for example, finding when two repeating events next align) use the LCM, which is smallest when the two numbers are relatively prime.
Frequently Asked Questions
What does it mean for two numbers to be relatively prime?
How do you calculate the GCD to check if two numbers are relatively prime?
Are two prime numbers always relatively prime?
Can zero or negative numbers be relatively prime?
Common Tip Percentages
| Service | Typical Tip Range | Notes |
|---|---|---|
| Restaurant (sit-down) | 15–20% | 20%+ for exceptional service |
| Food delivery | 10–20% | Consider extra for long distances |
| Taxi / rideshare | 10–20% | More for assistance with luggage |
| Hotel housekeeping | $2–5/night | Leave daily, not just at checkout |
| Barber / hair salon | 15–20% | On pre-discount total |
| Pizza delivery | 10–15% or $3–5 minimum | Higher in bad weather |
General Household Budget Ratios (50/30/20 Rule)
| Category | % of Net Income | Examples |
|---|---|---|
| Needs | 50% | Rent, groceries, utilities, insurance |
| Wants | 30% | Dining out, entertainment, hobbies |
| Savings / Debt | 20% | Emergency fund, retirement, extra payments |
Common Measurement Conversions for Everyday Use
| Quantity | US / Imperial | Metric Equivalent |
|---|---|---|
| 1 cup | 8 fl oz | 237 mL |
| 1 pint | 16 fl oz | 473 mL |
| 1 quart | 32 fl oz | 946 mL |
| 1 gallon | 128 fl oz | 3.785 L |
| 1 lb | 16 oz | 453.6 g |
| 1 ft | 12 in | 30.48 cm |