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.

A290691 Triangle read by rows: infinite braid made of periodically-colored yarns in which the crossing of two adjacent yarns occurs when two color 0's are side by side (see comments).

Original entry on oeis.org

1, 0, 2, 1, 1, 3, 0, 0, 2, 4, 2, 1, 1, 3, 5, 1, 0, 0, 2, 4, 6, 0, 3, 1, 1, 3, 5, 7, 2, 2, 0, 0, 2, 4, 6, 8, 1, 1, 4, 1, 1, 3, 5, 7, 9, 0, 0, 3, 0, 0, 2, 4, 6, 8, 10, 3, 2, 2, 5, 1, 1, 3, 5, 7, 9, 11, 2, 1, 1, 4, 0, 0, 2, 4, 6, 8, 10, 12, 1, 0, 0, 3, 6, 1, 1
Offset: 1

Views

Author

Luc Rousseau, Oct 20 2017

Keywords

Comments

Construction: row numbers start at n = 3; column numbers run from k = 1 to k = n - 2. For all y >= 2, a yarn called "yarn y" is made of the repeated (y - 1, y - 2, ..., 1, 0) sequence. Pin it (for now vertically) at coordinates (y + 1, y - 1). Progress by increasing n: for a given row n, if two adjacent yarns show side by side 0's, then cross them at this point.
Properties: n is a prime iff there is no 0 in row n. n is a square iff there is an isolated 0 in row n column 1. If there is a crossing between yarn y1 and yarn y2 in row n, then n = y1 * y2.
Alternative definition: row n is the list of (-n) mod (y) sorted in ascending order of abs(y - n / y), for all y candidate divisor of n, y between 2 and (n - 1) inclusive.

Examples

			Array begins:
1
0  2
1  1  3
0  0  2  4
2  1  1  3  5
1  0  0  2  4  6
0  3  1  1  3  5  7
2  2  0  0  2  4  6  8
1  1  4  1  1  3  5  7  9
...
Viewed as a braid (pairs of adjacent zeros being replaced by crossings):
        1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  ------> k
      .
   3    1
        |
   4    0   2
        |   |
   5    1   1   3
         \ /    |
   6      0     2   4
         / \    |   |
   7    2   1   1   3   5
        |    \ /    |   |
   8    1     0     2   4   6
        |    / \    |   |   |
   9    0   3   1   1   3   5   7
        |   |    \ /    |   |   |
  10    2   2     0     2   4   6   8
        |   |    / \    |   |   |   |
  11    1   1   4   1   1   3   5   7   9
         \ /    |    \ /    |   |   |   |
  12      0     3     0     2   4   6   8  10
         / \    |    / \    |   |   |   |   |
  13    3   2   2   5   1   1   3   5   7   9  11
        |   |   |   |    \ /    |   |   |   |   |
  14    2   1   1   4     0     2   4   6   8  10  12
        |    \ /    |    / \    |   |   |   |   |   |
  15    1     0     3   6   1   1   3   5   7   9  11  13
        |    / \    |   |    \ /    |   |   |   |   |   |
  16    0   4   2   2   5     0     2   4   6   8  10  12  14
        |   |   |   |   |    / \    |   |   |   |   |   |   |
  17    3   3   1   1   4   7   1   1   3   5   7   9  11  13  15
   |
   V   ...
   n
		

Crossrefs

Cf. A293578.

Programs

  • C
    #include 
    #include 
    #include 
    #define NMAX 40
    struct cell { int f; int v; };
    struct line { struct cell t[NMAX]; };
    void display(struct line *T) { int n, k; for (n = 3; n <= NMAX; n ++) { for (k = 1; k < n - 1; k ++) { printf("%2d, ", T[n].t[k].v, T[n].t[k].f); } printf("\n"); } }
    void swap(int *a, int *b) { int x; x = *a; *a = *b; *b = x; }
    void fill(struct line *T)
    {
        int n, k;
        for (n = 3; n <= NMAX; n ++)
        {
            for (k = 1; k < n - 2; k ++)
            {
                T[n].t[k].v = T[n - 1].t[k].v - 1;
                T[n].t[k].f = T[n - 1].t[k].f;
            }
            T[n].t[n - 2].v = n - 2;
            T[n].t[n - 2].f = n - 1;
            for (k = 1; k < n - 2; k ++)
            {
                if ((T[n].t[k].v == 0) && (T[n].t[k + 1].v == 0))
                {
                    swap(&T[n].t[k].f, &T[n].t[k + 1].f);
                }
            }
            for (k = 1; k < n - 2; k ++)
            {
                if (T[n].t[k].v == -1)
                {
                    T[n].t[k].v += T[n].t[k].f;
                }
            }
        }
    }
    int main() { struct line T[NMAX + 1]; memset(T, 0x0, sizeof(T)); fill(T); display(T); }
  • Mathematica
    Ev[E_] := Module[{x, dx}, x = First[E]; dx = Last[E]; If[x == 0 && dx < 0, {-dx, -dx}, {x + dx, dx}]]
    EvL[n_, L_] := Module[{LL}, LL = Ev /@ L; LL = Sort[LL]; LL = Append[LL, {n - 1, -1/n}]; LL]
    It[nStart_, nEnd_, LStart_] := Module[{n, LL}, For[n = nStart; LL = LStart, n <= nEnd, n++, LL = EvL[n, LL]]; LL]
    Encours[n_] := It[2, n, {}]
    Countdown[x_, dx_] := If[dx > 0, (Ceiling[x] - x)/dx, (Floor[x] - x)/dx]
    A[n_] := Drop[Apply[Countdown, #] & /@ Encours[n], -1]
    Table[A[n], {n, 2, 25}] // Flatten
    (* or *)
    (Last /@ # &) /@ Sort /@ Table[{Abs[k - n/k], Mod[-n, k]}, {n, 3, 20}, {k, 2, n - 1}] // Flatten

Formula

T(n,k) = (-n) mod y(n,k), with y(n,k) the yarn going through (n,k); ambiguity at a crossing doesn't matter, both mod yielding 0.