Repunit primes

Revision as of 14:54, 23 January 2022 by Thundergnat (talk | contribs) (New draft task and Raku example)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Repunit is a portmanteau of the words "repetition" and "unit", with unit being "unit value"... or in laymans terms, 1. So 1, 11, 111, 1111 & 11111 are all repunits.

Repunit primes is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

Every standard integer base has repunits since every base has the digit 1. This task involves finding the repunits in different bases that are prime.

In base two, the repunits 11, 111, 11111, 1111111, etc. are prime. (These correspond to the Merseene primes.)

In base three: 111, 1111111, 1111111111111, etc.

These repunit primes, by definition, are also circular primes.

Any repunit in any base having a composite number of digits is necessarily composite. Only repunits (in any base) having a prime number of digits might be prime.


Rather than expanding the repunit out as a giant list of 1s or converting to base 10, it is common to just list the number of 1s in the repunit; effectively the digit count. The base two repunit primes listed above would be represented as: 2, 3, 5, 7, etc.

Many of these sequences exist on OEIS, though they aren't specifically listed as a "repunit prime digits" sequences.

Some bases have very few repunit primes. Bases 4, 8, and likely 16 have only one. Base 9 has none at all. Bases above 16 may have repunit primes as well... but this task is getting large enough already.


Task
  • For bases 2 through 16, Find and show, here on this page, the repunit primes as digit counts, up to a limit of 1000.


Stretch
  • Increase the limit to 2700 (or as high as you have patience for.)


See also



Raku

<lang perl6>my $limit = 2700;

say "Repunit prime digits (up to $limit) in:";

.put for (2..16).hyper(:1batch).map: -> $base {

   $base.fmt("Base %2d: ") ~ (1..$limit).grep(&is-prime).grep( (1 x *).parse-base($base).is-prime )

}</lang>

Output:
Repunit prime digits (up to 2700) in:
Base  2: 2 3 5 7 13 17 19 31 61 89 107 127 521 607 1279 2203 2281
Base  3: 3 7 13 71 103 541 1091 1367 1627
Base  4: 2
Base  5: 3 7 11 13 47 127 149 181 619 929
Base  6: 2 3 7 29 71 127 271 509 1049
Base  7: 5 13 131 149 1699
Base  8: 3
Base  9: 
Base 10: 2 19 23 317 1031
Base 11: 17 19 73 139 907 1907 2029
Base 12: 2 3 5 19 97 109 317 353 701
Base 13: 5 7 137 283 883 991 1021 1193
Base 14: 3 7 19 31 41 2687
Base 15: 3 43 73 487 2579
Base 16: 2