Giuga Number Calculator

Check whether every prime divisor p of n divides n over p minus one.

Math and PercentUpdated 2026-11-182 min read
Giuga Number Calculator
A whole number from 2 to 1,000,000.
Classification
...
Distinct prime factors...
First failing prime...

What it does

A Giuga number is a composite integer n with the property that for every prime divisor p of n, the value n divided by p, minus one, is divisible by p. The first example is 30: for p equal to 2, 15 minus 1 is 14 which is even; for p equal to 3, 10 minus 1 is 9; and for p equal to 5, 6 minus 1 is 5.

The numbers are named after the Italian mathematician Giuseppe Giuga, who studied a related congruence condition. Giuga numbers are rare, and the sequence begins 30, 858, 1722 and 66198.

The condition can be checked directly from the prime factorization. This page tests each distinct prime in turn and reports the first one that fails, which makes it clear why a number did not qualify.

The input limit is one million, which keeps factoring fast. Values are exact and the tool reports a readable error outside the allowed range.

The related Giuga conjecture concerns prime numbers satisfying a similar congruence, but this page only tests composite Giuga numbers.

How to use

  1. Enter a composite number n from 2 to 1,000,000.
  2. Read the classification in the main result box.
  3. Check the count of distinct prime factors beside it.
  4. If a prime failed, its value is reported.
  5. The default n = 30 reproduces the worked example.
  6. Try n = 858 to confirm the second Giuga number.

Formula

n is Giuga when n is composite and for every prime p dividing n, p divides (n/p) - 1
n
The composite integer being tested.
p
A distinct prime divisor of n.
n/p - 1
The value that p must divide.

Because n divided by p is an integer, each test is an exact divisibility check. The number of distinct primes is reported, and primes are checked in increasing order so the first failure is deterministic.

Worked example

Example: n = 30

The page opens with n = 30.

  1. Factor 30 as 2 x 3 x 5, giving three distinct primes.
  2. For p = 2: 30/2 - 1 = 14, divisible by 2.
  3. For p = 3: 30/3 - 1 = 9, divisible by 3.
  4. For p = 5: 30/5 - 1 = 5, divisible by 5.
  5. All primes pass and 30 is composite.
  6. The tool reports Giuga number with three prime factors.

Reference table

Giuga numbers and nearby cases
nFactorizationPassing primesGiuga
302 x 3 x 52, 3, 5Yes
422 x 3 x 72, 3 fail at 7No
8582 x 3 x 11 x 13allYes
17222 x 3 x 7 x 41allYes

Limits

  • Only composite integers from 2 to 1,000,000 are tested.
  • Primes are excluded by definition.
  • The tool reports the first failing prime, not all failures.
  • Factorization limits the upper bound.

Common mistakes

  • Testing a prime and expecting a Giuga verdict.
  • Checking p divides n rather than n over p minus one.
  • Using only the largest prime factor.
  • Forgetting to subtract one after the division.
  • Assuming every number with three prime factors is Giuga.

Try it yourself

Quick checks. Answers sit tucked under each question.

Is 30 a Giuga number?

Yes, all three prime factors satisfy the divisibility condition.

Is 42 a Giuga number?

No, the prime 7 fails because 42/7 - 1 = 5 is not divisible by 7.

What is the second Giuga number?

858.

Questions

Who was Giuga?

Giuseppe Giuga was an Italian mathematician who studied related congruences.

Are Giuga numbers common?

No, they are very rare.

Is there a Giuga conjecture?

Yes, a conjecture that a certain congruence characterises primes.

Can a prime be a Giuga number?

No, the definition requires compositeness.

Are results exact?

Yes, the tests use integer divisibility.

What input range is accepted?

Whole numbers from 2 through 1,000,000.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.