OFFSET
1,1
COMMENTS
First prime p such that the expansion of 1/p has period (p-1)/n in base 8. Also the first prime p such that {k/p : 1 <= k <= p-1} has n different cycles when written out in base 8.
LINKS
Jean-François Alcover, Table of n, a(n) for n = 1..1000
EXAMPLE
In the following examples let () denote the reptend. The prime numbers themselves and the fractions are written out in decimal.
The base-8 expansion of 1/3 is 0.(25), so the reptend has length 2 = (3-1)/1. Also, the base-8 expansions of 1/3 = 0.(25) and 2/3 = 0.(52) have only one cycle 25. 3 is the smallest such prime, so a(1) = 3.
The base-8 expansion of 1/17 is 0.(03607417), so the reptend has length 8 = (17-1)/2. Also, the base-8 expansions of 1/17, 2/17, ..., 16/17 have two cycles 03607417 and 13226455. 17 is the smallest such prime, so a(2) = 17.
The base-8 expansion of 1/13 is 0.(0473), so the reptend has length 4 = (13-1)/3. Also, the base-8 expansions of 1/13, 2/13, ..., 12/13 have three cycles 0473, 1166 and 2354. 13 is the smallest such prime, so a(3) = 13.
MATHEMATICA
a[n_] := a[n] = For[p = 2, True, p = NextPrime[p], If[MultiplicativeOrder[8, p] == (p-1)/n, Return[p]]];
Table[Print[n, " ", a[n]]; a[n], {n, 1, 100}] (* Jean-François Alcover, Nov 24 2024 *)
PROG
(PARI) a(n, {base=8}) = forprime(p=2, oo, if((base%p) && znorder(Mod(base, p)) == (p-1)/(n * if(issquare(base), 2, 1)), return(p)))
CROSSREFS
KEYWORD
nonn
AUTHOR
Jianing Song, May 13 2024
STATUS
approved