OFFSET
1,3
LINKS
Eric Weisstein's MathWorld, Modular Inverse
FORMULA
3 * a(n) == 1 (mod prime(n)).
a(n) = (p * (-1)^((r+1)/2))/3 mod p = q * (-1)^((r+1)/2) mod p where p = prime(n) = 3*q + r, with r = -1 or 1 and quotient q a positive integer. - Ian George Walker, Mar 24 2021
a(n) = ceiling(2p/3)/(p mod 3) where p is the n-th prime, a(2)=0. - Travis Scott, Feb 08 2023
EXAMPLE
3*5 mod prime(4) = 15 mod 7 = 1, so a(4) = 5.
MAPLE
a:= n-> `if`(n=2, 0, (p-> ceil(2*p/3)/(p mod 3))(ithprime(n))):
seq(a(n), n=1..75); # Alois P. Heinz, Feb 08 2023
MATHEMATICA
a[n_] := ModularInverse[3, Prime[n]]; Table[a[n], {n, 3, 100}]
Table[If[Mod[Prime@n, 3]==0, 0, ModularInverse[3, Prime@n]], {n, 88}]
PROG
(PARI) a(n) = if (n==2, 0, lift(1/Mod(3, prime(n)))); \\ Michel Marcus, Mar 31 2021
CROSSREFS
KEYWORD
nonn
AUTHOR
Jean-François Alcover, May 02 2017
EXTENSIONS
Name edited and a(1)-a(2) prepended by Travis Scott, Feb 08 2023
STATUS
approved