OFFSET
1,2
COMMENTS
With the exception of the prime numbers 2 and 5, the values of r mentioned above form the sequence A006556.
Detection of all different cycles of digits in the decimal expansions of 1/p, 2/p, ..., (p-1)/p where p=n-th prime. If for the n-th prime p the number of different cycles of digits is equal to r, then there will be the smallest integer b in the interval 0 < b < p with the following property: The fractions (b^0)/p, (b^1)/p, ..., (b^(r-1))/p will produce r different cycles of digits. In this case the term a(n) of the sequence becomes equal to b.
EXAMPLE
For n=13, prime(13)=41, there are A006556(13)=8 cycles.
With b=3, we get (normally, these fractions should be in the form (b^k mod p)/p):
frac(3^0 / 41) = 0.02439 (1)
frac(3^1 / 41) = 0.07317 (2)
frac(3^2 / 41) = 0.21951 (3)
frac(3^3 / 41) = 0.65853 (4)
frac(3^4 / 41) = 0.97560 (5)
frac(3^5 / 41) = 0.92682 (6)
frac(3^6 / 41) = 0.78048 (7)
frac(3^7 / 41) = 0.34146 (8=r)
So a(13) = 3.
PROG
(PARI) \\ default(realprecision, 1000)
nbc(p) = (p-1)/znorder(Mod(10, p));
len(p) = znorder(Mod(10, p));
pad(x, sz) = {while(#digits(x) != sz, x*=10); x; }
cmpc(x, y) = {if (x==y, return (0)); my(dx=digits(x), dy=digits(y), v=dx); for (k=1, #dx, v=vector(#v, k, if (k==#v, v[1], v[k+1])); if (v == dy, return (0)); ); return (1); }
decimals(x, sz) = pad(floor(1.0*10^sz*x), sz);
a(n) = {my(p=prime(n)); if ((p==2), return (1)); if ((p==5), return (2)); my(sz=len(p), nb=nbc(p), m=1); while (#vecsort(vector(f(p), k, decimals((m^(k-1) % p)/p, sz)), cmpc, 8) != nb, m++); m; } \\ Michel Marcus, May 29 2020
CROSSREFS
KEYWORD
nonn,base
AUTHOR
George Plousos, May 15 2020
STATUS
approved