Knodel Number Calculator

Modular arithmetic

Is 561 a Knodel number for k = 1?Yes - every base coprime to 561 satisfies a^560 = 1 (mod 561)
Euler totient phi(n) - coprime bases tested320
Exponent n - k560
Smallest failing baseNo failing base
How this was calculated
  1. A Knodel number for a given k is a composite n such that every base a coprime to n satisfies a^(n - k) congruent to 1 modulo n; k = 1 gives the Carmichael numbers.
  2. For n = 561 and k = 1 the exponent is 560 and there are phi(561) = 320 coprime bases to test.
  3. Every one of those bases returns 1, so the Knodel condition holds for k = 1.
  4. So 561 is a Knodel number for k = 1.

The Knodel Number Calculator checks whether a composite number n is a Knodel number for a given k. A Knodel number for a given k is a composite n such that a^(n-k) is congruent to 1 mod n for every base a coprime to n. Enter n and k, and the calculator tests each coprime base and tells you whether n passes for all of them. The idea generalises Carmichael numbers, and for k = 1 the Knodel numbers are exactly the Carmichael numbers: 561, the smallest Carmichael number, passes with exponent 560 over all 320 coprime bases. For k = 2, 14 is a Knodel number — every coprime base satisfies a^12 congruent to 1 mod 14 — while 15 is not, because base 2 already fails, since 2^13 mod 15 = 2, not 1. The Knodel numbers for k = 2 begin 4, 6, 8, 10, 12, 14, 22, 24, 26, 30.

Testing every base coprime to n is the accepted standard for this kind of calculation: the definition itself requires the congruence to hold for all coprime bases, so a single failing base is enough to rule a number out, as base 2 does for 15 with k = 2. Knodel numbers generalise Carmichael numbers and were studied by Walter Knodel. This page shows the formula, step-by-step workings, worked examples and sources, so you can follow exactly how each result is reached.

Worked examples

561, the smallest Carmichael number

(561 · 1)

Is 561 a Knodel number for k = 1?Yes - every base coprime to 561 satisfies a^560 = 1 (mod 561)
Euler totient phi(n) - coprime bases tested320
Exponent n - k560
Smallest failing baseNo failing base

14, a Knodel number for k = 2

(14 · 2)

Is 14 a Knodel number for k = 2?Yes - every base coprime to 14 satisfies a^12 = 1 (mod 14)
Euler totient phi(n) - coprime bases tested6
Exponent n - k12
Smallest failing baseNo failing base

15, which fails for k = 2

(15 · 2)

Is 15 a Knodel number for k = 2?No - base 2 gives 2^13 = 2 (mod 15), not 1
Euler totient phi(n) - coprime bases tested8
Exponent n - k13
Smallest failing base2

What is a Knodel number?

A Knodel number is defined by a congruence condition rather than by how its digits look. For a given k, a composite number n is a Knodel number when a^(n-k) is congruent to 1 modulo n for every base a that is coprime to n. In other words, pick any number a that shares no factor with n, raise it to the power n minus k, divide by n, and the remainder must always be 1. If even one coprime base produces a remainder other than 1, n does not qualify for that k. The definition only applies to composite n, so primes are excluded from the start.

The value of k changes which numbers qualify, and the case k = 1 is especially important. When k is 1, the exponent becomes n - 1, and the Knodel numbers are exactly the Carmichael numbers. Carmichael numbers are the classic troublemakers for simple primality tests: they are composite, yet they mimic primes by satisfying a^(n-1) congruent to 1 mod n for every base a coprime to n. The smallest Carmichael number is 561, and it passes this test with exponent 560 over all 320 coprime bases. So 561 is a Knodel number for k = 1, and every other Carmichael number is one too.

Other values of k produce their own families. Take k = 2, so the exponent is n - 2. The number 14 is a Knodel number for k = 2: every base coprime to 14 satisfies a^12 congruent to 1 mod 14. By contrast, 15 is not a Knodel number for k = 2, because the base 2 already fails. Since 2^13 mod 15 equals 2, not 1, a single counterexample is enough to disqualify 15. This shows why the definition insists on every coprime base: one failing base settles the matter.

The k = 2 list begins 4, 6, 8, 10, 12, 14, 22, 24, 26, 30. These are not the Carmichael numbers, so the choice of k genuinely selects a different collection of composites. Knodel numbers generalise Carmichael numbers, and they were studied by Walter Knodel. The generalization is useful because it turns a single special case, k = 1, into a whole spectrum of conditions indexed by k, each with its own qualifying composites and its own counterexamples.

To check whether a number is a Knodel number for a given k, you test the congruence a^(n-k) congruent to 1 mod n across the bases coprime to n. Finding one base that fails is enough to rule the number out, as with 15 and base 2 for k = 2. Confirming the condition requires that every coprime base passes, which is why the definition is stated as a universal requirement rather than a single test.

For k = 1, Knodel numbers are exactly the Carmichael numbers; for k = 2, the list begins 4, 6, 8, 10, 12, 14, 22, 24, 26, 30.

How the test works

To decide whether a number n is a Knodel number for a given k, a calculator first needs to know which bases a are coprime to n. It counts those bases with Euler's totient function φ(n), which gives the number of integers from 1 to n that share no factor with n. That count is the size of the test set: every base a coprime to n must satisfy the congruence a^(n-k) ≡ 1 (mod n). The calculator then tests the coprime bases one by one, in increasing order, using modular exponentiation to compute a^(n-k) mod n. As soon as a base fails — that is, its result is not 1 — the test stops and reports that smallest failing base. If no coprime base fails, n passes for that k.

The procedure is easiest to see with 561, the smallest Carmichael number. For k = 1, a Knodel number is a composite n with a^(n-1) ≡ 1 (mod n) for every base a coprime to n — exactly the definition of a Carmichael number. The calculator finds φ(561) = 320, so there are 320 coprime bases to check. It tests each base with exponent n − k = 560. Every one of the 320 bases satisfies a^560 ≡ 1 (mod 561), so 561 passes and is reported as a Knodel number for k = 1.

For k = 2 the exponent becomes n − 2. The calculator works through the coprime bases in order and stops at the first failure. Take n = 14: the coprime bases are tested with exponent 12, and every one satisfies a^12 ≡ 1 (mod 14). No base fails, so 14 is reported as a Knodel number for k = 2. Now take n = 15: the first coprime base is 2, and the calculator computes 2^13 mod 15 = 2, which is not 1. The test stops immediately and reports base 2 as the smallest failing base, so 15 is not a Knodel number for k = 2.

This base-by-base search is why the Knodel number test can be both exact and efficient: it never needs to test a base that shares a factor with n, and it can quit at the first counterexample. The Knodel numbers for k = 2 begin 4, 6, 8, 10, 12, 14, 22, 24, 26, 30 — each one passes the full set of coprime bases with exponent n − 2. Knodel numbers generalise Carmichael numbers and were studied by Walter Knodel.

Smallest failing base: for 15 with k = 2, base 2 fails because 2^13 mod 15 = 2, not 1.

Knodel numbers by k

The value of k decides which numbers belong to the family. A Knodel number for a given k is a composite n such that a^(n-k) is congruent to 1 mod n for every base a coprime to n. Change k by one, and the exponent in that test changes by one, so the set of numbers that pass can shift completely. The two smallest cases show how little the families overlap.

For k = 1, the Knodel numbers are exactly the Carmichael numbers, so the list opens with 561, the smallest Carmichael number. In that case the exponent is n minus 1, the familiar Carmichael condition: 561 passes with exponent 560 over all 320 coprime bases. Anyone who has met Carmichael numbers has therefore already met the k = 1 case of this family.

For k = 2, the exponent becomes n minus 2, and a different collection of numbers qualifies. The Knodel numbers for k = 2 begin 4, 6, 8, 10, 12, 14, 22, 24, 26, 30. The first entry, 4, is not a Carmichael number at all, so the two lists do not build on each other. A single example makes the test concrete: 14 is a Knodel number for k = 2 because every coprime base satisfies a^12 congruent to 1 mod 14. The neighboring case fails just as plainly: 15 is not a Knodel number for k = 2, since base 2 already fails, with 2^13 mod 15 equal to 2, not 1. Passing or failing turns on the interaction between the modulus and the exponent, not on size alone.

The table below sets the two cases side by side. The k = 1 row names the family rather than listing its members, because for that case the Knodel numbers are exactly the Carmichael numbers.

kKnodel numbersExample check
1Exactly the Carmichael numbers; 561 is the smallest561 passes with exponent 560 over all 320 coprime bases
2Begins 4, 6, 8, 10, 12, 14, 22, 24, 26, 3014 passes: a^12 is congruent to 1 mod 14 for every coprime base; 15 fails, since 2^13 mod 15 = 2, not 1
Knodel numbers generalise Carmichael numbers and were studied by Walter Knodel. The k = 1 case recovers the Carmichael numbers exactly; larger k values open separate families.

Knodel vs Carmichael vs pseudoprimes

A Fermat pseudoprime is a composite number that behaves like a prime for one particular base: it satisfies the Fermat congruence for that base even though it is not prime. That is a narrow kind of deception. It can pass a single test and still be exposed by another base, so a Fermat pseudoprime is only a pretender to primality for the base or bases on which it happens to work.

A Carmichael number is far more convincing. It passes the Fermat test with exponent n - 1 for every base a that is coprime to n, not just one. The smallest Carmichael number, 561, passes with exponent 560 over all 320 coprime bases. A Carmichael number therefore defeats the plain Fermat test no matter which coprime base you choose, which is why it matters in the study of primality testing.

A Knodel number takes that idea and moves the exponent. For a given k, a Knodel number is a composite n such that a^(n-k) is congruent to 1 mod n for every base a coprime to n. The exponent is n - k rather than n - 1, so the Knodel number generalises Carmichael numbers: for k = 1, the Knodel numbers are exactly the Carmichael numbers. Knodel numbers were studied by Walter Knodel.

Small examples make the difference concrete. The number 14 is a Knodel number for k = 2: every coprime base satisfies a^12 congruent to 1 mod 14. The number 15 is not a Knodel number for k = 2, because base 2 already fails, since 2^13 mod 15 = 2, not 1. One failing coprime base is enough to disqualify a candidate, just as one failing base exposes a Fermat pseudoprime.

The Knodel numbers for k = 2 begin 4, 6, 8, 10, 12, 14, 22, 24, 26, 30. The list starts with very small composites, which shows how the shifted exponent changes which numbers qualify. A composite that passes for every coprime base under one exponent can fail under another, and the Knodel number framework is what lets you compare those cases directly.

  • Fermat pseudoprime: passes the Fermat test for one base (or a few), not all.
  • Carmichael number: passes with exponent n - 1 for every coprime base; 561 is the smallest, passing with exponent 560 over all 320 coprime bases.
  • Knodel number for a given k: a composite n with a^(n-k) congruent to 1 mod n for every base a coprime to n.
  • For k = 1, the Knodel numbers are exactly the Carmichael numbers.
  • 14 is a Knodel number for k = 2 (a^12 congruent to 1 mod 14 for every coprime base); 15 is not, since 2^13 mod 15 = 2, not 1.
Knodel numbers generalise Carmichael numbers by shifting the exponent from n - 1 to n - k. Setting k = 1 recovers the Carmichael numbers exactly.

FAQs

What is a Knodel number?

For a fixed k, a Knodel number is a composite number n such that a^(n-k) = 1 (mod n) for every base a that is coprime to n. This condition extends the idea of Carmichael numbers to a shifted exponent, so the definition depends on the chosen value of k.

Is 561 a Knodel number?

Yes. For k = 1, the Knodel condition is exactly the definition of a Carmichael number, and 561 is the smallest Carmichael number. So 561 satisfies the Knodel requirement for k = 1, since every base coprime to 561 gives a^(561-1) = 1 (mod 561).

Is 14 a Knodel number for k = 2?

Yes. For k = 2, the test requires a^(14-2) = a^12 = 1 (mod 14) for every base a coprime to 14. Every such base satisfies a^12 = 1 (mod 14), so 14 meets the Knodel condition for k = 2 even though 14 is composite.

Is 15 a Knodel number for k = 2?

No. For k = 2, base 2 must satisfy 2^(15-2) = 2^13 = 1 (mod 15). But 2^13 mod 15 equals 2, not 1, so 15 fails the condition immediately. A single failing coprime base is enough to disqualify n, so 15 is not a Knodel number for k = 2.

How many bases must be tested for n?

You must test every base coprime to n, and there are Euler's totient phi(n) such bases. For n = 561, phi(561) is 320, so 320 coprime bases must be checked. If any one of them fails to give a^(n-k) = 1 (mod n), then n is not a Knodel number for that k.

Who were Knodel numbers named after?

Knodel numbers are named after the Austrian mathematician Walter Knodel, who studied this generalization of Carmichael numbers. His work extended the Carmichael condition to a shifted exponent, giving the family of composite numbers now called Knodel numbers for a fixed value of k.

Sources

Related calculators

Carmichael Number Calculator
Test whether a number is a Carmichael number with Korselt's criterion - squarefree with p - 1 dividing n - 1 for every prime factor - and see its full factorization.
Carmichael Function Calculator
The Carmichael function lambda(n), the smallest universal exponent modulo n, from the prime factorization, compared with Euler's totient.
Legendre Symbol Calculator
The Legendre symbol (a/p): whether a is a quadratic residue modulo an odd prime p, checked against the full residue list and Euler's criterion.