Circular Prime Calculator

Number

Is 197 a circular prime?Yes - all 3 rotations are prime
Rotations tested197, 971, 719
Number of rotations3
Next circular prime after 197199
How this was calculated
  1. A circular prime stays prime under every cyclic rotation of its decimal digits, so each rotation must be tested as a number in its own right.
  2. The rotations of 197 are 197, 971, 719.
  3. Testing them one by one: 197 is prime and 971 is prime and 719 is prime.
  4. So 197 is a circular prime, and the next one after it is 199.

This circular prime calculator checks whether a prime number stays prime under every cyclic rotation of its decimal digits, and it shows you the result for any number you enter. A circular prime is a prime number that stays prime under every cyclic rotation of its decimal digits. For example, 197 is a circular prime because its 3 rotations — 197, 971 and 719 — are all prime, and the next circular prime after 197 is 199. The four-digit circular prime 1,193 has 4 rotations — 1,193, 1,931, 9,311 and 3,119 — all prime, and the next circular prime after 1,193 is 1,931. Not every prime qualifies: 23 is not a circular prime, because its rotation 32 is composite, and the next circular prime after 23 is 31. The calculator also explains the small cases: 2, 3, 5 and 7 are trivially circular primes, and 13 is the smallest multi-digit circular prime.

The method behind the answer is the accepted standard for this kind of calculation: it rotates the digits through every possible position and tests each rotation for primality, exactly the definition given above. That same rule explains a useful shortcut the calculator applies — a multi-digit number containing any of the digits 0, 2, 4, 5, 6 or 8 can never be circular, because some rotation puts that digit last and makes the number even or a multiple of 5. This page shows the formula, step-by-step workings, worked examples and sources, so you can follow each rotation and each primality test rather than just reading a final yes or no.

Worked examples

197, a circular prime

(197)

Is 197 a circular prime?Yes - all 3 rotations are prime
Rotations tested197, 971, 719
Number of rotations3
Next circular prime after 197199

1,193, a four-digit circular prime

(1193)

Is 1,193 a circular prime?Yes - all 4 rotations are prime
Rotations tested1,193, 1,931, 9,311, 3,119
Number of rotations4
Next circular prime after 1,1931,931

23, not circular - 32 is composite

(23)

Is 23 a circular prime?No - rotation 32 is composite
Rotations tested23, 32
Number of rotations2
Next circular prime after 2331

What a circular prime is

A circular prime is a prime number that stays prime under every cyclic rotation of its decimal digits. A cyclic rotation means taking the digits from the front and moving them to the back, one at a time, until every possible starting point has been tried. If all of those rotated numbers are prime, the original number is circular. If even one rotation is composite, the number fails the test. A circular prime calculator applies exactly this rule: it generates each rotation and checks whether the result is prime.

The single-digit primes 2, 3, 5 and 7 are trivially circular primes, since rotating a one-digit number changes nothing. The smallest multi-digit circular prime is 13: its rotation 31 is also prime. Larger examples show how the idea works in practice. 197 is a circular prime because its three rotations — 197, 971 and 719 — are all prime, and the next circular prime after 197 is 199. 1,193 is a four-digit circular prime: its four rotations 1,193, 1,931, 9,311 and 3,119 are all prime, and the next circular prime after 1,193 is 1,931.

Failing the test is just as instructive. 23 is not a circular prime, because its rotation 32 is composite; the next circular prime after 23 is 31. That example captures the whole definition in miniature: a number can be prime itself and still be disqualified by a single bad rotation.

There is also a quick shortcut that rules out most multi-digit candidates before any rotation is checked. A multi-digit number containing any of the digits 0, 2, 4, 5, 6 or 8 can never be circular, because some rotation puts that digit last, and a number ending in an even digit is even, while a number ending in 0 or 5 is a multiple of 5. Either way, that rotation is composite, so the number cannot qualify. This is why multi-digit circular primes are built only from the digits 1, 3, 7 and 9 — with the special exception of the single-digit primes 2 and 5, which are circular only because they have no rotation to fail.

Put together, these facts give a clear picture of what the term means: primality that survives every cyclic shift of the digits, not just the original arrangement. The examples above — 13, 197, 1,193 and the failing case of 23 — cover the definition from the smallest multi-digit case to a four-digit one, and they show both what qualifies and what does not.

Remember: a multi-digit number containing 0, 2, 4, 5, 6 or 8 can never be a circular prime, because some rotation ends in that digit and is therefore even or a multiple of 5.

How the rotation test works

A circular prime calculator runs one simple idea over and over: rotate the digits one step at a time and test every rotation for primality. A circular prime is a prime number that stays prime under every cyclic rotation of its decimal digits. If even one rotation turns out composite, the number fails the test and is not circular. The order of the digits never changes — only which digit sits at the front.

Take 197. The first rotation is the number itself, 197, which is prime. Shift the leading digit to the back and you get 971, which is prime. Shift again and you get 719, which is prime. That is all 3 rotations, and every one passed, so 197 is a circular prime. For comparison, the next circular prime after 197 is 199.

Now walk 1,193 through the same test. Its 4 rotations are 1,193, 1,931, 9,311 and 3,119, and each of those is prime, so 1,193 is a four-digit circular prime. The next circular prime after 1,193 is 1,931 — which, as it happens, is already one of the rotations you just checked. A four-digit number always produces exactly four rotations, so the test ends after the fourth step.

The test also shows quickly when a number fails. Consider 23: it is prime, but its rotation 32 is composite, so 23 is not a circular prime. The next circular prime after 23 is 31. Single digits are a special case: 2, 3, 5 and 7 are trivially circular primes, since rotating a one-digit number leaves it unchanged. Among multi-digit numbers, 13 is the smallest circular prime.

There is a shortcut worth knowing before you rotate anything. A multi-digit number containing any of the digits 0, 2, 4, 5, 6 or 8 can never be circular, because some rotation puts that digit last and makes the number even or a multiple of 5. That single rule screens out most candidates, and the circular prime calculator then applies the rotation test only to the numbers that survive.

  • Rotate the digits one position at a time, moving the leading digit to the end.
  • Test each rotation for primality; all of them must be prime.
  • Stop as soon as one rotation is composite — the number is not circular.
NumberRotations testedAll prime?Circular prime?
197197, 971, 719YesYes
1,1931,193, 1,931, 9,311, 3,119YesYes
2323, 32No (32 is composite)No
2, 3, 5, 7Single digit, unchangedYesYes (trivially)
1313, 31YesYes (smallest multi-digit)
197 passes all 3 rotations (197, 971, 719); 1,193 passes all 4 (1,193, 1,931, 9,311, 3,119). 23 fails, because its rotation 32 is composite.

Digits that rule a number out at once

Before you run a single division test, you can often rule a number out of the circular prime club just by looking at its digits. A circular prime is a prime number that stays prime under every cyclic rotation of its decimal digits. That rotation rule is strict, and it is what makes certain digits instantly disqualifying. In any multi-digit number, the presence of a 0, 2, 4, 5, 6 or 8 means the number can never be circular, no matter how the rest of its digits are arranged.

The reason is simple: a cyclic rotation moves every digit around the loop, so whatever digits a number contains will eventually land in the last position. A number whose final digit is even is divisible by 2. A number whose final digit is 5 is divisible by 5. A number ending in 0 is divisible by both 10 and 5. So if a multi-digit number contains a 0, 2, 4, 5, 6 or 8, some rotation puts that digit last and makes the number even or a multiple of 5. That rotation is composite, and the original number fails the definition. This is the fastest filter a circular prime calculator can apply, and it costs nothing but a glance at the digits.

Notice the careful wording: multi-digit. The single digits 2, 3, 5 and 7 are trivially circular primes, because each has only one rotation, itself, and each is prime. A lone 2 or 5 is not disqualified, since there is no separate rotation to turn it into an even number or a multiple of 5. The digit rule bites only once a number has at least two digits, where a rotation can actually move a bad digit into the units place. That is why 13, the smallest multi-digit circular prime, is built only from odd digits that are not 5.

The digit filter catches many candidates, but it does not catch everything. A number can be made entirely of allowed digits and still fail, because a rotation can produce a composite number for reasons that have nothing to do with its final digit. The classic small example is 23. Every digit in 23 is fine, and 23 itself is prime, yet 23 is not a circular prime, because its rotation 32 is composite. The next circular prime after 23 is 31. This is why the digit rule is a first pass and not the whole test: passing it means a number deserves the full rotation check, not that it has earned the label.

The same logic explains why the known circular primes look the way they do. 197 is a circular prime: its 3 rotations 197, 971 and 719 are all prime, and the next circular prime after 197 is 199. 1,193 is a four-digit circular prime: its 4 rotations 1,193, 1,931, 9,311 and 3,119 are all prime, and the next circular prime after 1,193 is 1,931. Every one of those digits avoids the forbidden set, which is exactly what the rule predicts. Use the digit screen first, then confirm each rotation.

  • Forbidden digits in a multi-digit number: 0, 2, 4, 5, 6 or 8.
  • Why: some rotation puts that digit last, making the number even or a multiple of 5.
  • Exception: the single digits 2, 3, 5 and 7 are trivially circular primes.
  • Passing the digit screen is necessary but not sufficient: 23 fails because its rotation 32 is composite.
A circular prime calculator can discard any multi-digit candidate containing 0, 2, 4, 5, 6 or 8 immediately — but surviving that screen, as 23 shows, is only the start of the test.

Circular primes and repunits

Repunits get their name from the fact that they are made entirely of repeated 1s: 11, 111, 1111, and so on. The connection to circular primes is simple and worth knowing. If a number consists only of repeated 1s and it is prime, then every cyclic rotation of it is the same string of 1s, so every rotation is that same prime. That makes every repunit prime circular by definition. The repunit itself does not need any special checking, because rotating a block of identical digits cannot produce a different number. This is one of the few families of circular primes you can identify without testing rotations one by one.

For everything else, the circular prime calculator has to do real work. Take 197: its three rotations are 197, 971 and 719, and all three are prime, so 197 qualifies. The next circular prime after 197 is 199. The four-digit example 1,193 works the same way: its four rotations are 1,193, 1,931, 9,311 and 3,119, all prime, and the next circular prime after 1,193 is 1,931. Not every prime survives the test. The number 23 is prime, but its rotation 32 is composite, so 23 is not circular; the next circular prime after 23 is 31.

The single digits 2, 3, 5 and 7 are trivially circular primes, since a one-digit number has only one rotation, itself. The smallest multi-digit circular prime is 13. Beyond that point, a simple digit rule eliminates most candidates before any primality test: a multi-digit number containing any of the digits 0, 2, 4, 5, 6 or 8 can never be circular. The reason is that some rotation puts that digit last, and a number ending in an even digit is even, while one ending in 0 or 5 is a multiple of 5. Either way the rotation is composite, so the original number fails.

That rule helps explain why circular primes thin out quickly as the digit count grows. Long numbers have many rotations, and every one of them must be prime; a single composite rotation is enough to disqualify the whole number. The digits available to build candidates are limited to 1, 3, 7 and 9, which sharply reduces the pool. Repunit primes sit inside that pool, but they are rare themselves, and they are the only circular primes whose rotations are all identical. For any other candidate, each rotation is a distinct number that has to pass the test on its own.

A circular prime calculator makes the check mechanical: rotate the digits through every position, test each result for primality, and report whether all of them pass. Use it to confirm examples like 197 and 1,193, to see why 23 fails, and to explore how far the circular primes reach before the growing number of required rotations makes them increasingly scarce.

Every repunit prime is circular, because rotating a string of identical 1s gives back the same prime. For all other numbers, every rotation must be prime — one composite rotation is enough to disqualify the number.

FAQs

Is 197 a circular prime?

Yes. 197 is a circular prime because all 3 of its rotations are prime: 197, 971 and 719. Every rotation must be prime for a number to qualify, and here each one passes, so 197 counts as a circular prime under the standard definition.

Is 23 a circular prime?

No. 23 is not a circular prime because one of its rotations, 32, is composite. A circular prime requires every rotation to be prime, and 32 fails that test since it is even and greater than 2. So 23 does not qualify.

What is the next circular prime after 197?

The next circular prime after 197 is 199. You reach it by checking numbers in order above 197 and testing each one's rotations for primality. 199 qualifies, so it is the next circular prime following 197 in the sequence.

Is 1,193 a circular prime?

Yes. 1,193 is a circular prime because all 4 of its rotations are prime: 1,193, 1,931, 9,311 and 3,119. Each rotation passes the primality test, so the number meets the requirement that every rotation be prime.

Why can a multi-digit number containing the digit 2 never be a circular prime?

Because some rotation puts the 2 last, making that rotation an even number greater than 2, hence composite. Since every rotation must be prime, one composite rotation is enough to disqualify the number. That is why a multi-digit number containing the digit 2 can never be a circular prime.

What is the smallest multi-digit circular prime?

The smallest multi-digit circular prime is 13. Both of its rotations, 13 and 31, are prime, so it qualifies. Single-digit primes also count as circular primes, but among numbers with more than one digit, 13 is the smallest that passes the rotation test.

Sources

Related calculators

Emirp Calculator
Test whether a prime is an emirp - a prime whose digit reversal is a different prime - checking both directions and excluding palindromic primes.
Euclid Number Calculator
Compute the Euclid number E(n) - the product of the first n primes plus 1 - with its primorial, factorization and digit count.
Repunit Calculator
Build the repunit of n ones in any base, show its exact value and digit string, and test whether it is prime or factor it.