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-4 of 4 results.

A141002 a(n) = total number of different ways a grasshopper can take n hops.

Original entry on oeis.org

1, 1, 1, 2, 3, 4, 7, 12, 21, 37, 63, 116, 208, 372, 682, 1255, 2334, 4277, 7951, 14905, 27967, 52334, 98222, 186344, 352621, 666933, 1264406, 2413511, 4604124, 8766995, 16748492, 32124034, 61642942, 118049157, 226709069, 436727197, 841581933, 1619406091
Offset: 0

Views

Author

David Applegate and N. J. A. Sloane, Jul 21 2008

Keywords

Comments

Consider a grasshopper (cf. A141000) that starts at x=0 at time 0, then makes successive hops of sizes 1, 2, 3, ..., n, subject to the constraint that it must always land on a point x >= 0; sequence gives number of different ways that it can make n hops.
Here, unlike A141000, there is no restriction on how large x can be (of course x <= n(n+1)/2).

Examples

			For example, for n=3 the grasshopper can hit 0=1+2-3 or 6=1+2+3; for n=4 it can hit 2=1+2+3-4, 4=1+2-3+4, or 10=1+2+3+4. For n=7 we can reach 8 in two different ways, which explains the first place where this sequence differs from A141001.
		

Crossrefs

A360173 Irregular triangle (an infinite binary tree) read by rows. The tree has root node 0, in row n=0. Each node then has left child m - n if nonnegative and right child m + n. Where m is the value of the parent node and n is the row of the children.

Original entry on oeis.org

0, 1, 3, 0, 6, 4, 2, 10, 9, 7, 5, 15, 3, 15, 1, 13, 11, 9, 21, 10, 8, 22, 8, 6, 20, 4, 18, 2, 16, 14, 28, 2, 18, 0, 16, 14, 30, 0, 16, 14, 12, 28, 12, 10, 26, 10, 8, 24, 6, 22, 20, 36, 11, 9, 27, 9, 7, 25, 5, 23, 21, 39, 9, 7, 25, 5, 23, 3, 21, 19, 37, 3, 21
Offset: 0

Views

Author

John Tyler Rascoe, Jan 28 2023

Keywords

Comments

A node will have a left child only if the value of that child is greater than or equal to 0. But, each node will have a right child, since adding n will always be greater than 0.
The n-th row will have A141002(n) nodes. The leftmost border is A008344 and the rightmost is A000217.

Examples

			The binary tree starts with root 0 in row n = 0. In row n = 3, the parent node m = 3 has the first left child since 3 - 3 >= 0.
The tree begins:
row
[n]
[0]           0
               \
[1]             1
                 \
[2]            ___3___
              /       \
             /         \
[3]         0         __6__
             \       /     \
[4]           4     2      10
               \     \    /  \
[5]             9     7  5    15
		

Crossrefs

Row sums give A360229.

Programs

  • Maple
    T:= proc(n) option remember; `if`(n=0, 0, map(x->
          [`if`(xAlois P. Heinz, Jan 30 2023
  • Mathematica
    row[n_] := Module[{r = {0}}, For[h = 1, h <= n, h++, r = Flatten[If[#-h >= 0, {#-h, #+h}, {#+h}]& /@ r]]; r];
    Table[row[n], {n, 0, 10}] // Flatten (* Jean-François Alcover, Apr 16 2025, after Rémy Sigrist *)
  • PARI
    row(n) = { my (r=[0]); for (h=1, n, r=concat(apply(v->if (v-h>=0, [v-h,v+h], [v+h]), r))); return (r) } \\ Rémy Sigrist, Jan 31 2023
  • Python
    def A360173_rowlist(row_n):
        A = [[0]]
        for i in range(0,row_n):
            A.append([])
            for j in range(0,len(A[i])):
                x = A[i][j]
                if x - i -1 >= 0:
                    A[i+1].append(x-i-1)
                if x + i + 1 >= 0:
                    A[i+1].append(x+i+1)
        return(A)
    

A360229 Row sums of triangle A360173.

Original entry on oeis.org

0, 1, 3, 6, 16, 36, 73, 156, 324, 677, 1405, 2864, 5906, 12058, 24548, 49928, 101434, 206173, 417141, 844256, 1707622, 3452998, 6970196, 14058528, 28368774, 57197983, 115239846, 232020596, 467296470, 940684267, 1892396396, 3805806218, 7654402454, 15391563411
Offset: 0

Views

Author

John Tyler Rascoe, Jan 30 2023

Keywords

Crossrefs

Programs

  • Maple
    b:= proc(n) option remember; `if`(n=0, 1, (p->
           add((t-> `if`(i
          add(i*coeff(p, x, i), i=0..degree(p)))(b(n))
        end:
    seq(a(n), n=0..35);  # Alois P. Heinz, Jan 30 2023
  • Mathematica
    b[n_] := b[n] = If[n == 0, 1, Function[p, Sum[Function[t, If[iJean-François Alcover, Apr 24 2025, after Alois P. Heinz *)

A360255 Irregular triangle (an infinite binary tree) read by rows: see Comments section for definition.

Original entry on oeis.org

0, 1, 3, 6, 2, 10, 7, 5, 15, 13, 11, 9, 21, 20, 4, 18, 2, 16, 14, 28, 12, 28, 12, 26, 8, 24, 22, 20, 36, 21, 19, 37, 21, 17, 35, 17, 33, 13, 31, 11, 29, 27, 45, 11, 31, 9, 29, 27, 47, 31, 7, 27, 25, 45, 7, 27, 23, 43, 23, 41, 19, 39, 17, 37, 35, 55, 22, 42, 18
Offset: 0

Views

Author

John Tyler Rascoe, Jan 30 2023

Keywords

Comments

The binary tree has root node 0, in row n=0. The left child is m - n and the right child is m + n, where m is the parent node and n is the row of the child. A given node will only have a child if the child is nonnegative and the value of the child is not present in the path from the parent to the root, including the root value itself.
The n-th row will have A321535(n) nodes. The rightmost border is A000217.

Examples

			The binary tree starts with root 0 in row n = 0. In row n = 3, the parent node m = 3 does not have a left child since 3 - 3 = 0 is included in the path from the parent to the root {3,1,0}.
The tree begins:
row
[n]
[0]           0
               \
[1]             1
                 \
[2]               3
                   \
[3]               __6__
                 /     \
[4]             2      10
                 \    /  \
[5]               7  5    15
		

Crossrefs

Programs

  • MATLAB
    function a = A360255( max_row )
        p = 0; a = 0; pos = 1;
        for n = 1:max_row
            for k = pos:length(a)
                h =[]; o = p(k);
                while o > 0
                    h = [h a(o)]; o = p(o);
                end
                if a(k)-n > 0
                    if isempty(find(h == a(k)-n, 1))
                        p = [p k]; a = [a a(k)-n];
                    end
                end
                if isempty(find(h == a(k)+n, 1))
                    p = [p k]; a = [a a(k)+n];
                end
            end
            pos = k+1;
        end
    end % Thomas Scheuerle, Jan 31 2023
Showing 1-4 of 4 results.