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.

Showing 1-3 of 3 results.

A379822 Triangle read by rows: T(n, k) is the number of walks of length n on the Z X Z grid with unit steps in all four directions (NSWE) starting at (0, 0), and ending on the vertical line x = 0 if k = 0, or on the line x = k or x = -(n + 1 - k) if k > 0.

Original entry on oeis.org

1, 2, 2, 6, 5, 5, 20, 16, 12, 16, 70, 57, 36, 36, 57, 252, 211, 130, 90, 130, 211, 924, 793, 507, 286, 286, 507, 793, 3432, 3004, 2016, 1092, 728, 1092, 2016, 3004, 12870, 11441, 8024, 4488, 2380, 2380, 4488, 8024, 11441, 48620, 43759, 31842, 18717, 9384, 6120, 9384, 18717, 31842, 43759
Offset: 0

Views

Author

Peter Luschny, Jan 16 2025

Keywords

Examples

			  [0] [    1]
  [1] [    2,     2]
  [2] [    6,     5,     5]
  [3] [   20,    16,    12,    16]
  [4] [   70,    57,    36,    36,   57]
  [5] [  252,   211,   130,    90,  130,  211]
  [6] [  924,   793,   507,   286,  286,  507,  793]
  [7] [ 3432,  3004,  2016,  1092,  728, 1092, 2016,  3004]
  [8] [12870, 11441,  8024,  4488, 2380, 2380, 4488,  8024, 11441]
  [9] [48620, 43759, 31842, 18717, 9384, 6120, 9384, 18717, 31842, 43759]
.
For n = 3 we get the walks depending on the x-coordinate of the endpoint:
W(x= 3) = {WWW},
W(x= 2) = {NWW,WWN,WNW,SWW,WSW,WWS},
W(x= 1) = {NNW,NWN,WNN,NSW,NWS,SWN,SNW,WWE,WEW,EWW,WNS,WSN,SWS,SSW,WSS},
W(x= 0) = {NNN,NNS,NSN,NWE,NEW,SNN,EWN,WNE,WEN,ENW,SNS,SSN,SWE,SEW,WSE,WES,ESW,EWS,NSS,SSS},
W(x=-1) = {NNE,ENN,NEN,NSE,NES,SNE,SEN,WEE,ENS,ESN,EWE,EEW,SSE,SES,ESS},
W(x=-2) = {NEE,SEE,ENE,ESE,EEN,EES},
W(x=-3) = {EEE}.
T(3, 0) = card(W(x=0)) = 20, T(3, 1) = card(W(x=1)) + card(W(x=-3)) = 16,
T(3, 2) = card(W(x=2)) + card(W(x=-2)) = 12, T(3, 3) = card(W(x=3)) + card(W(x=-1)) = 16.
		

Crossrefs

Related triangles: A052174 (first quadrant), A378067 (upper plane), this triangle (whole plane).
Cf. A000984 (column 0), A323229 (column 1 and main diagonal), A000302 (row sums), A068551 (row sum without column 0), A283799 (row minimum).

Programs

  • Maple
    T := (n, k) -> binomial(2*n, n - k) + binomial(2*n, k - 1):
    seq(print(seq(T(n, k), k = 0..n)), n = 0..9);
  • Mathematica
    A379822[n_, k_] := Binomial[2*n, n - k] + Binomial[2*n, k - 1];
    Table[A379822[n, k], {n, 0, 10}, {k, 0, n}] (* Paolo Xausa, May 29 2025 *)
  • Python
    from dataclasses import dataclass
    @dataclass
    class Walk:
        s: str = ""
        x: int = 0
        y: int = 0
    def Trow(n: int) -> list[int]:
        W = [Walk()]
        row = [0] * (n + 1)
        for w in W:
            if len(w.s) == n:
                row[w.x] += 1
            else:
                for s in "NSWE":
                    x = y = 0
                    match s:
                        case "W": x =  1
                        case "E": x = -1
                        case "N": y =  1
                        case "S": y = -1
                        case _  : pass
                    W.append(Walk(w.s + s, w.x + x, w.y + y))
        return row
    for n in range(10): print(Trow(n))

Formula

T(n, k) = binomial(2*n, n - k) + binomial(2*n, k - 1).
Sum_{k=1..n} T(n, k) = A068551(n).

A380120 Triangle read by rows: T(n, k) is the number of walks of length n on the Z X Z grid with unit steps in all four directions (NSWE) starting at (0, 0). k is the absolute value of the x-coordinate of the endpoint of the walk.

Original entry on oeis.org

1, 2, 2, 6, 8, 2, 20, 30, 12, 2, 70, 112, 56, 16, 2, 252, 420, 240, 90, 20, 2, 924, 1584, 990, 440, 132, 24, 2, 3432, 6006, 4004, 2002, 728, 182, 28, 2, 12870, 22880, 16016, 8736, 3640, 1120, 240, 32, 2, 48620, 87516, 63648, 37128, 17136, 6120, 1632, 306, 36, 2
Offset: 0

Views

Author

Peter Luschny, Jan 17 2025

Keywords

Examples

			Triangle starts:
  [0] [    1]
  [1] [    2,     2]
  [2] [    6,     8,     2]
  [3] [   20,    30,    12,     2]
  [4] [   70,   112,    56,    16,     2]
  [5] [  252,   420,   240,    90,    20,    2]
  [6] [  924,  1584,   990,   440,   132,   24,    2]
  [7] [ 3432,  6006,  4004,  2002,   728,  182,   28,   2]
  [8] [12870, 22880, 16016,  8736,  3640, 1120,  240,  32,  2]
  [9] [48620, 87516, 63648, 37128, 17136, 6120, 1632, 306, 36, 2]
.
For n = 0 there is only the empty walk w = '' with start and end point (x=0, y=0).
For n = 3 the walks depending on the x-coordinate of the endpoint are:
W(x= 3) = {WWW},
W(x= 2) = {NWW,SWW,WNW,WSW,WWN,WWS},
W(x= 1) = {NNW,NSW,NWN,NWS,SNW,SSW,SWN,SWS,WNN,WNS,WSN,WSS,WWE,WEW,EWW},
W(x= 0) = {NNN,NNS,NSN,NSS,NWE,NEW,SNN,SNS,SSN,SSS,SWE,SEW,WNE,WSE,WEN,WES,ENW,ESW,EWN,EWS},
W(x=-1) = {NNE,NSE,NEN,NES,SNE,SSE,SEN,SES,WEE,ENN,ENS,ESN,ESS,EWE,EEW},
W(x=-2) = {NEE,SEE,ENE,ESE,EEN,EES},
W(x=-3) = {EEE}.
T(3, 0) = card(W(x=0)) = 20, T(3, 1) = card(W(x=1)) + card(W(x=-1)) = 30,
T(3, 2) = card(W(x=2)) + card(W(x=-2)) = 12, T(3, 3) = card(W(x=3)) + card(W(x=-3)) = 2.
		

Crossrefs

Related triangles: A052174 (N X N), A378067 (Z X N), A379822 (Z X Z, variant), A380119.
Cf. A000984 (column 0), A162551 (column 1), A006659 (column 2), A000302 (row sums), A068551 (row sum without column 0), A040000 (row minimum).

Programs

  • Maple
    T := (n, k) -> ifelse(k = 0, binomial(2*n, n - k), 2*binomial(2*n, n - k)):
    seq(print(seq(T(n, k), k = 0..n)), n = 0..9);
  • Python
    from dataclasses import dataclass
    @dataclass
    class Walk:
        s: str = ""
        x: int = 0
        y: int = 0
    def Trow(n: int) -> list[int]:
        W = [Walk()]
        row = [0] * (n + 1)
        for w in W:
            if len(w.s) == n:
                row[abs(w.x)] += 1
            else:
                for s in "NSWE":
                    x = y = 0
                    match s:
                        case "W": x =  1
                        case "E": x = -1
                        case "N": y =  1
                        case "S": y = -1
                        case _  : pass
                    W.append(Walk(w.s + s, w.x + x, w.y + y))
        return row
    for n in range(10): print(Trow(n))

Formula

T(n, k) = binomial(2*n, n - k) if k = 0, otherwise 2*binomial(2*n, n - k).
Assuming the columns starting at n = 0, i.e. prepended by k zeros:
T(n, k) = [x^n] (2^(2*k+1)*x^k / (sqrt(1-4*x)*(1+sqrt(1-4*x))^(2*k))) for k >= 1.
T(n, k) = n! * [x^n] (2*BesselI(k, 2*x)*exp(2*x)) for k >= 1.

A380121 a(n) = C(n, Q(n+3, 4)-1)*C(n, Q(n+1, 4)) + C(n, Q(3*n+1, 4))*C(n, Q(3*n+3, 4)) where C = binomial and Q(x, y) = floor(x/y).

Original entry on oeis.org

1, 2, 3, 6, 20, 50, 126, 294, 1008, 2592, 7425, 18150, 62920, 163592, 496860, 1242150, 4331600, 11328800, 35581680, 90140256, 315490896, 828163602, 2658338298, 6793531206, 23836951600, 62728820000, 204451146900, 525731520600, 1848025951200, 4872068416800, 16059866355000
Offset: 0

Views

Author

Peter Luschny, Jan 17 2025

Keywords

Comments

a(n) is the minimum of row n of A378067 except at n = 1.

Crossrefs

Cf. A378067.

Programs

  • Maple
    a := n -> binomial(n, iquo(n+3, 4)-1) * binomial(n, iquo(n+1, 4)) + binomial(n, iquo(3*n+1, 4)) * binomial(n,iquo(3*n+3, 4)): seq(a(n), n = 0..29);
  • Python
    from math import comb as C
    def a(n): return C(n,(n+3)//4-1)*C(n,(n+1)//4)+C(n,(3*n+1)//4)*C(n,(3*n+3)//4) if n>0 else 1; print([a(n) for n in range(31)])
Showing 1-3 of 3 results.