Repunit Calculator

Repunit

Repunit R_5 in base 1011,111
Digit string11111 (base 10)
PrimalityComposite: 41 x 271
Number of digits5
How this was calculated
  1. A repunit is a number made only of ones: R_n in base b is a string of n ones, with no other digits allowed.
  2. The closed form is R_n = (b^n - 1) / (b - 1), so here (10^5 - 1) / (10 - 1) = 11,111.
  3. Written out in base 10, the value is 11111 - exactly 5 ones in a row, which is the defining digit pattern of a repunit.
  4. Testing the result: 11,111 is composite: 41 x 271. Repunit primes are rare and can only occur when the number of digits is itself prime.

This repunit calculator works with repunits: numbers written with nothing but the digit 1. In base b, the repunit R_n is a string of n ones, and its closed form is R_n = (b^n - 1) / (b - 1). Enter a base and a digit count, and the calculator gives you the repunit itself along with what you most likely want to know: whether that number is prime or composite. The results are concrete. R_2 in base 10 is 11, which is prime. R_5 in base 10 is 11,111 = 41 x 271, so it is composite. In base 2, R_3 = 111 (binary) = 7, which is prime. The calculator applies the same check across the bases and lengths you choose, so you can compare results side by side instead of testing numbers by hand.

The method behind the results is the accepted standard for this kind of calculation because it rests on the defining structure of a repunit rather than on guesswork. The closed form R_n = (b^n - 1) / (b - 1) generates each term exactly, and primality is settled by testing the resulting integer, not by assuming a pattern. That matters because a repunit can only be prime when its number of digits is prime, so the digit count narrows the search before any factoring begins. This page shows the formula, the step-by-step workings, worked examples, and the sources behind them, so you can follow every result from the input to the answer and check it yourself.

Worked examples

R_5 = 11,111 = 41 x 271

(5 · 10)

Repunit R_5 in base 1011,111
Digit string11111 (base 10)
PrimalityComposite: 41 x 271
Number of digits5

R_2 = 11 is prime

(2 · 10)

Repunit R_2 in base 1011
Digit string11 (base 10)
PrimalityPrime
Number of digits2

The binary repunit 111 is 7

(3 · 2)

Repunit R_3 in base 27
Digit string111 (base 2)
PrimalityPrime
Number of digits3

What is a repunit?

A repunit is a number written using only the digit 1, repeated some number of times. The name comes from "repeated unit," and the idea is as simple as it sounds: 1, 11, 111, 1111, and so on. In base 10, the number with n ones is written R_n, so R_1 is 1, R_2 is 11, R_3 is 111, and R_5 is 11,111. Every repunit in base 10 is therefore a string of ones with no other digits and no leading zeros, which makes them easy to recognize at a glance. A repunit calculator works with these strings directly, so you can specify how many ones you want and see the resulting number without counting digits by hand.

The definition extends beyond base 10. In a general base b, the repunit R_n is the number whose representation in base b is a string of n ones. The value of that string has a compact closed form: R_n = (b^n - 1) / (b - 1). This formula converts the digit-string view into ordinary arithmetic. For base 10 it gives (10^n - 1) / 9, which produces 11 for n = 2 and 11,111 for n = 5. For base 2 it gives (2^n - 1) / 1, which is simply 2^n - 1, so the binary string of n ones equals one less than the nth power of two.

Whether a repunit is prime depends on both the base and the number of digits. In base 10, R_2 is 11, and 11 is prime. R_5 in base 10 is 11,111, and 11,111 = 41 x 271, so it is composite. In base 2, R_3 is the binary string 111, which equals 7, and 7 is prime. These examples show that a short repunit can be prime while a longer one in the same base may not be, so the digit count alone does not guarantee a prime result.

There is a useful rule that narrows the search: a repunit can only be prime when its number of digits is prime. If the count of digits is composite, the repunit can be factored, so it cannot be prime. That rule is a filter, not a promise. A prime digit count does not make the repunit prime automatically, which is why a repunit calculator is handy for checking specific cases rather than assuming an answer from the length alone.

  • Base 10: R_n is a string of n ones, such as 11, 111, and 11,111.
  • General base b: R_n = (b^n - 1) / (b - 1).
  • R_2 in base 10 is 11, which is prime.
  • R_5 in base 10 is 11,111 = 41 x 271, so it is composite.
  • In base 2, R_3 = 111 (binary) = 7, which is prime.
  • A repunit can only be prime when its number of digits is prime.
A repunit is a string of ones, but its value depends on the base: 111 is 111 in base 10 and 7 in base 2.

Worked values

The best way to see how a repunit calculator works is to follow a few small cases by hand. Start with R_5 in base 10, the number made of five ones: 11,111. Because a repunit is a number consisting only of the digit 1, and R_n in base b is a string of n ones, R_5 is simply the five-digit string 11111 written out as 11,111. The closed form R_n = (b^n - 1) / (b - 1) gives the same result: (10^5 - 1) / (10 - 1) = 99,999 / 9 = 11,111.

That value is composite. R_5 in base 10 is 11,111 = 41 x 271, so it is composite. Checking the multiplication confirms the digits: 41 x 271 = 11,111. This is a useful reminder that a repunit being built entirely from ones says nothing about whether it is prime; the digit pattern is visual, not a guarantee of primality. A repunit calculator that factors the value exposes this immediately, turning the string of ones into a product of two smaller numbers.

Contrast that with the shortest nontrivial case in base 10. R_2 in base 10 is 11, which is prime. Here the closed form gives (10^2 - 1) / (10 - 1) = 99 / 9 = 11, and 11 has no divisors other than 1 and itself. So the same construction that produced a composite at n = 5 produces a prime at n = 2.

The base matters as much as the length. In base 2, R_3 = 111 (binary) = 7, which is prime. The closed form agrees: (2^3 - 1) / (2 - 1) = 7 / 1 = 7. The same three ones that would read as 111 in base 10 read as 7 in base 2, and the primality result follows the value, not the written digits. This is also where a useful rule of thumb appears: a repunit can only be prime when its number of digits is prime. R_2 and R_3 both have prime digit counts and both are prime in the cases shown, while R_5 has a prime digit count but is still composite — so the rule is a necessary condition, not a sufficient one. The calculator handles that distinction for you by testing the actual value rather than relying on the digit count alone.

RepunitBaseValueStatus
R_21011Prime
R_327Prime
R_51011,111 = 41 x 271Composite
A repunit can only be prime when its number of digits is prime — but a prime digit count does not guarantee a prime repunit, as R_5 = 11,111 = 41 x 271 shows.

Repunit primes

A repunit is a number made up entirely of the digit 1. In base b, the repunit R_n is a string of n ones, and its closed form is R_n = (b^n - 1) / (b - 1). When people ask whether a repunit is prime, there is a useful rule to check first: the number of digits must itself be prime. This is a necessary condition, not a guarantee, and understanding the difference between the two is the key to using a repunit calculator sensibly.

The reason the digit count must be prime comes from the closed form. If the number of digits n can be factored, the repunit can be factored too, so a repunit with a composite digit count is always composite. That means a repunit can only be prime when its number of digits is prime. The condition narrows the search a great deal, but it does not settle the question. A prime digit count passes the first test; it does not promise a prime result.

The base-10 repunit R_5 is the standard counterexample. Five is prime, so R_5 clears the necessary condition. Yet R_5 in base 10 is 11,111, and 11,111 = 41 x 271, so it is composite. A prime digit count was not enough. This is exactly why the rule is stated as necessary rather than sufficient, and why a repunit calculator should report the factorization rather than stopping at the digit-count check.

Small cases show both outcomes. R_2 in base 10 is 11, which is prime, so a prime digit count can produce a prime repunit. In base 2, R_3 = 111 (binary) = 7, which is prime. Here the digit count is 3, also prime, and the base-2 repunit is prime as well. Reading these examples together with R_5 gives the full picture: prime digit count is required, and sometimes it is enough, but sometimes it is not.

In practice, the digit-count rule is a fast filter. Before testing a repunit for primality, check whether its number of digits is prime. If it is not, the number is composite and no further work is needed. If it is, the repunit may still be composite, as R_5 in base 10 demonstrates. A good repunit calculator uses the rule to skip hopeless cases, then does the real work on the survivors.

R_5 in base 10 is 11,111 = 41 x 271. Five is prime, yet the repunit is composite, so a prime digit count is necessary but not sufficient.

Repunits and divisibility

A repunit is a number consisting only of the digit 1: R_n in base b is a string of n ones. The closed form is R_n = (b^n - 1) / (b - 1). That formula is the key to divisibility, because it rewrites a string of ones as a ratio of powers of the base. A repunit calculator can evaluate this expression directly for any base and length, but the structure behind it also tells you, before you divide anything, which numbers are likely to divide the result.

The base itself matters first. Because R_n = (b^n - 1) / (b - 1), every repunit is tied to b - 1: the quantity b - 1 divides b^n - 1 for every n, and that relationship shapes how repunits behave in a given base. In base 10, where b - 1 = 9, this connection is familiar from the digit-sum test for divisibility by 9. For a prime a, the order of b modulo a governs which repunits a prime divides: the order is the smallest positive n for which b^n leaves a remainder of 1 when divided by a, and a prime divides R_n exactly when n is a multiple of that order. So a single order value determines an entire family of repunits that the prime divides, not just one.

Concrete examples make the pattern visible. R_2 in base 10 is 11, which is prime. R_5 in base 10 is 11,111 = 41 x 271, so it is composite. The same rule holds in other bases: in base 2, R_3 = 111 (binary) = 7, which is prime. Notice the lengths: 2, 5 and 3. A repunit can only be prime when its number of digits is prime, which is why a composite digit count like 5 rules out primality for R_5 even before you find its factors.

For anyone using a repunit calculator, these facts turn trial division into a short checklist. If the number of ones is composite, the repunit is composite, so no further factoring is needed to settle primality. If the digit count is prime, the repunit may still be composite, as R_5 shows, and the order of the base modulo a candidate prime tells you whether that prime divides it. The order also explains why factors repeat at regular intervals of n rather than appearing at random.

  • b - 1 divides b^n - 1 for every n, linking each repunit to the base minus one.
  • A prime a divides R_n exactly when n is a multiple of the order of b modulo a.
  • R_2 in base 10 is 11, which is prime; R_5 in base 10 is 11,111 = 41 x 271, so it is composite.
  • In base 2, R_3 = 111 (binary) = 7, which is prime.
A repunit can only be prime when its number of digits is prime, but a prime digit count does not guarantee a prime repunit: R_5 has five digits and still factors as 41 x 271.

FAQs

What is a repunit?

A repunit is a number made only of ones, like 11 or 11,111 — n ones in a row in the chosen base. The name comes from "repeated unit." The simplest example is 11, which is two ones in base 10. Repunits can be written in any base, so the same idea applies to numbers such as 111 in binary.

Is 11,111 prime?

No. R_5 = 11,111 = 41 x 271. Because it can be written as the product of 41 and 271, it is composite rather than prime. This is a useful example: a repunit with five digits looks unusual, but it still factors. Checking a repunit for primality means testing whether it has divisors beyond 1 and itself.

What is R_2?

R_2 is 11, which is prime — the smallest repunit prime. It is simply two ones in a row in base 10. Since 11 has no divisors other than 1 and 11, it qualifies as prime. That makes R_2 the first repunit prime you meet when going up in digit count.

Can a repunit with a composite number of digits be prime?

No — if the digit count factors, the repunit factors too, so the digit count must be prime. In other words, a repunit with a composite number of digits can be broken into smaller factors and cannot be prime. This is why candidates for repunit primes are sought among digit counts that are themselves prime.

What is the repunit formula?

The repunit formula is R_n = (b^n - 1) / (b - 1) in base b. Here n is the number of ones, and b is the base. For base 10, plugging in a value of n gives the repunit with that many ones. The formula lets you compute a repunit directly instead of writing out the digits one by one.

What is R_3 in base 2?

R_3 in base 2 is 111 in binary, which is 7 in decimal, and prime. Three ones in a row in base 2 represent the decimal number 7. Since 7 has no divisors other than 1 and itself, it is prime. This shows how the same repunit pattern behaves differently depending on the base you choose.

Sources

Related calculators

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.
Woodall Number Calculator
Compute the Woodall number W(n) = n x 2^n - 1, show its factorization and primality, and count its digits.
Proth Number Calculator
Proth numbers k x 2^n + 1 with the form check and Proth's theorem primality test built in.