cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A215747 a(n) = (-2)^n mod n.

Original entry on oeis.org

0, 0, 1, 0, 3, 4, 5, 0, 1, 4, 9, 4, 11, 4, 7, 0, 15, 10, 17, 16, 13, 4, 21, 16, 18, 4, 1, 16, 27, 4, 29, 0, 25, 4, 17, 28, 35, 4, 31, 16, 39, 22, 41, 16, 28, 4, 45, 16, 19, 24, 43, 16, 51, 28, 12, 32, 49, 4, 57, 16, 59, 4, 55, 0, 33, 64, 65, 16, 61, 44, 69, 64, 71, 4, 7
Offset: 1

Views

Author

Alex Ratushnyak, Aug 23 2012

Keywords

Comments

n^(n+2) mod (n+2) is essentially the same.
Indices of 0's: 2^k - 1, k>=0.
Indices of 1's: A006521 except the first term.
Indices of 3's: A015940.
Indices of 5's: 7, 133, 1517, 11761, ...
a(A000040(n)) = A000040(n)-2 = A040976(n).

Examples

			a(5) = (-2)^5 mod 5 = -32 mod 5 = 3.
		

Crossrefs

Programs

  • Maple
    a:= n-> (-2)&^n mod n:
    seq(a(n), n=1..100);  # Alois P. Heinz, Apr 08 2015
  • Mathematica
    a[n_]:=Mod[(-2)^n ,n]; Array[a,75] (* Stefano Spezia, Aug 25 2025 *)
  • Python
    for n in range(1, 333):
        print((-2)**n % n, end=',')