cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A372799 Smallest prime p such that the multiplicative order of 9 modulo p is 2*n, or 0 if no such prime exists.

Original entry on oeis.org

5, 13, 67, 313, 41, 61, 883, 433, 271, 2161, 683, 193, 1223, 8317, 2131, 769, 2551, 1621, 8513, 2521, 8779, 4357, 5843, 3889, 7451, 16069, 3079, 19993, 14327, 661, 23747, 95617, 42703, 2857, 15401, 17209, 2887, 7297, 547, 13441, 4019, 757, 41453, 29833, 54631, 31741, 20399
Offset: 1

Views

Author

Jianing Song, May 13 2024

Keywords

Comments

First prime p such that the expansion of 1/p has period (p-1)/(2*n) in base 9. Also the first prime p such that {k/p : 1 <= k <= p-1} has 2*n different cycles when written out in base 9.
Since ord(a^m,k) = ord(a,k)/gcd(m,ord(a,k)) for gcd(a,k) = 1, we have that (p-1)/ord(9,p) = ((p-1)/ord(3,p)) * gcd(2,ord(3,p)) is always even. Here ord(a,k) is the multiplicative order of a modulo k.

Examples

			In the following examples let () denote the reptend. The prime numbers themselves and the fractions are written out in decimal.
The base-9 expansion of 1/5 is 0.(17), so the reptend has length 2 = (5-1)/2. Also, the base-9 expansions of 1/5 = 0.(17), 2/5 = (0.35), 3/5 = 0.(53) and 4/5 = 0.(71) have two cycles 17 and 35. 5 is the smallest such prime, so a(1) = 5.
The base-9 expansion of 1/13 is 0.(062), so the reptend has length 3 = (13-1)/4. Also, the base-9 expansions of 1/13, 2/13, ..., 12/13 have four cycles 062, 134, 268 and 475. 13 is the smallest such prime, so a(2) = 13.
The base-9 expansion of 1/67 is 0.(01178285332), so the reptend has length 11 = (67-1)/6. Also, the base-9 expansions of 1/67, 2/67, ..., 66/67 have six cycles 01178285332, 02367581664, 03556877106, 04746273438, 07224865213 and 08414261545. 67 is the smallest such prime, so a(3) = 67.
		

Crossrefs

Programs

  • Mathematica
    a[n_] := a[n] = For[p = 2, True, p = NextPrime[p], If[MultiplicativeOrder[9, p] == (p-1)/(2n), Return[p]]];
    Table[Print[n, " ", a[n]]; a[n], {n, 1, 100}] (* Jean-François Alcover, Nov 24 2024 *)
  • PARI
    a(n,{base=9}) = forprime(p=2, oo, if((base%p) && znorder(Mod(base,p)) == (p-1)/(n * if(issquare(base), 2, 1)), return(p)))