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.

A385104 Triangle read by rows: T(n,k) is the number of residue classes obtained by solving mod(x^2,n) = k for x over the integers, n >= 1, k >= 0.

Original entry on oeis.org

1, 1, 1, 1, 2, 0, 2, 2, 0, 0, 1, 2, 0, 0, 2, 1, 2, 0, 1, 2, 0, 1, 2, 2, 0, 2, 0, 0, 2, 4, 0, 0, 2, 0, 0, 0, 3, 2, 0, 0, 2, 0, 0, 2, 0, 1, 2, 0, 0, 2, 1, 2, 0, 0, 2, 1, 2, 0, 2, 2, 2, 0, 0, 0, 2, 0, 2, 4, 0, 0, 4, 0, 0, 0, 0, 2, 0, 0, 1, 2, 0, 2, 2, 0, 0, 0, 0, 2, 2, 0, 2, 1, 2, 2, 0, 2, 0, 0, 1, 2
Offset: 1

Views

Author

Jason Bard, Jun 18 2025

Keywords

Comments

The sum of each row is n.

Examples

			Triangle starts:
  1
  1 1
  1 2 0
  2 2 0 0
  1 2 0 0 2
  1 2 0 1 2 0
  1 2 2 0 2 0 0
  2 4 0 0 2 0 0 0
  3 2 0 0 2 0 0 2 0
  1 2 0 0 2 1 2 0 0 2
  ...
		

Crossrefs

Programs

  • Mathematica
    dat[n_] := Table[Reduce[Mod[x^2, n] == k, x, Integers], {k, 0, n - 1}]; countConditions[cond_] := Which[cond === False, 0, MatchQ[cond, x \[Element] Integers], 1, True, Length@Cases[cond, Equal[x, _], Infinity]]; counts = Flatten[Table[countConditions /@ dat[n], {n, 1, 20}]]
  • PARI
    T(n, k) = sum(i=1, n, Mod(i,n)^2 == k);
    row(n) = vector(n, i, T(n, i-1)); \\ Michel Marcus, Jun 23 2025

Formula

T(n,0) = A000188(n).
T(n,1) = A060594(n).
T(n,n-1) = A000089(n).