login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A379544
a(n) = ((p-1)^n + (p+1)^n) mod p^2, where p is the n-th prime.
0
0, 2, 5, 2, 110, 2, 238, 2, 414, 2, 682, 2, 1066, 2, 1410, 2, 2006, 2, 2546, 2, 3066, 2, 3818, 2, 4850, 2, 5562, 2, 6322, 2, 7874, 2, 9042, 2, 10430, 2, 11618, 2, 13026, 2, 14678, 2, 16426, 2, 17730, 2, 19834, 2, 22246, 2, 23766, 2, 25546, 2, 28270, 2, 30666
OFFSET
1,2
EXAMPLE
For n = 3, prime(n) = 5, so a(3) = (5-1)^3 + (5+1)^3 mod 5^2 = 280 mod 25 = 5.
MATHEMATICA
Table[p=Prime[n]; Mod[((p-1)^n+(p+1)^n), p^2], {n, 57}] (* James C. McMahon, Jan 07 2025 *)
PROG
(Python)
import sympy
def a(n):
nth_prime = sympy.prime(n)
nth_prime_sq = nth_prime**2
return (pow(nth_prime-1, n, nth_prime_sq) + pow(nth_prime+1, n, nth_prime_sq)) % (nth_prime_sq)
CROSSREFS
Sequence in context: A328264 A170908 A229029 * A055385 A160503 A108429
KEYWORD
nonn,new
AUTHOR
Do Thanh Nhan, Dec 24 2024
STATUS
approved