OFFSET
3,1
COMMENTS
Let Z_3p be the ring of integers {0,1,2,...,3p-1} under mod 3p addition and multiplication. Form a subring S from the multiples of 3 in Z_3p. a(n) is the multiplicative identity of S. For example, a(4) = 15 because 7 is the 4th prime and 15 is the multiplicative identity of the subring {0,3,6,9,12,15,18} of Z_21. - Geoffrey Critzer, Jul 03 2015
LINKS
Michael S. Branicky, Table of n, a(n) for n = 3..10002 (terms 3..1000 from Harvey P. Dale)
Eric Weisstein's World of Mathematics, Chinese Remainder Theorem
FORMULA
a(n) = 2*prime(n)+1 if prime(n)==1 mod 3 and prime(n)+1 otherwise.
MATHEMATICA
Drop[DeleteDuplicates[Flatten[Table[p = Prime[n]; Select[Table[Table[PowerMod[a, n, 3 p], {n, 1, p - 1}], {a, Range[3, 3 p - 2, 3]}], Length[Union[#]] == 1 &], {n, 1, 50}]]], 1] (* Geoffrey Critzer, Jul 03 2015 *)
sps[n_]:=Module[{k=3, pr=Prime[n]}, While[Mod[k, pr]!=1, k=k+3]; k]; Array[ sps, 60, 3] (* Harvey P. Dale, Aug 05 2016 *)
Table[ChineseRemainder[{0, 1}, {3, n}], {n, Prime[Range[3, 60]]}] (* Harvey P. Dale, Jul 31 2019 *)
PROG
(PARI) a(n) = my(p=prime(n)); if (p % 3 == 1, 2*p+1, p+1); \\ Michel Marcus, Jul 04 2015
(Python)
from sympy import prime, primerange
def f(p): return 2*p+1 if p%3 == 1 else p+1
def aupton(nn): return [f(p) for p in primerange(5, prime(nn)+1)]
print(aupton(58)) # Michael S. Branicky, Jun 15 2021
CROSSREFS
KEYWORD
nonn
AUTHOR
Jon Perry, Jul 17 2014
EXTENSIONS
More terms from Michel Marcus, Jul 04 2015
STATUS
approved