%I #8 May 13 2024 12:19:47
%S 5,13,67,313,41,61,883,433,271,2161,683,193,1223,8317,2131,769,2551,
%T 1621,8513,2521,8779,4357,5843,3889,7451,16069,3079,19993,14327,661,
%U 23747,95617,42703,2857,15401,17209,2887,7297,547,13441,4019,757,41453,29833,54631,31741,20399
%N Smallest prime p such that the multiplicative order of 9 modulo p is 2*n, or 0 if no such prime exists.
%C 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.
%C 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.
%e In the following examples let () denote the reptend. The prime numbers themselves and the fractions are written out in decimal.
%e 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.
%e 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.
%e 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.
%o (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)))
%Y Cf. A211245, A364867.
%Y In other bases: A101208, A101209, A372797, A372798, A054471, A372800.
%K nonn
%O 1,1
%A _Jianing Song_, May 13 2024