OFFSET
1,4
COMMENTS
It is known that a(n) equals 1 when 2*n+1 is prime as a result of Fermat's little theorem. If not then a(n) equals 1 when 2*n+1 is a pseudoprime to base 2.
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..20000 (first 5000 terms from Muniru A Asiru)
Wikipedia, Fermat's little theorem
FORMULA
a(n) = 2^(2*n) mod (2*n+1) or a(n) = 4^n mod (2*n+1)
EXAMPLE
a(3) = 2^(2 * 3) mod (2 * 3 + 1) = 64 mod 7 = 1.
a(4) = 2^(2 * 4) mod (2 * 4 + 1) = 256 mod 9 = 4.
a(5) = 2^(2 * 5) mod (2 * 5 + 1) = 1024 mod 11 = 1.
MAPLE
seq(2&^(2*n) mod (2*n + 1), n=1..10^2); # Muniru A Asiru, Jan 14 2018
MATHEMATICA
Table[PowerMod[2, 2n, 2n + 1], {n, 90}] (* Harvey P. Dale, May 09 2012 *)
PROG
(Literate Haskell) > map (\k -> 2^(2*k) `mod` (2*k+1)) [1..100]
(GAP) A177023 := List([1..10^3], n -> 2^(2*n) mod (2*n + 1)); # Muniru A Asiru, Jan 14 2018
(PARI) a(n) = lift(Mod(4, 2*n+1)^n); \\ Michel Marcus, Jan 15 2018
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Nikolay Ulyanov (ulyanick(AT)gmail.com), May 01 2010
STATUS
approved