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

A326413 Successive squares visited by a knight on the single-digit square spiral, with ties resolved towards the left.

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, Oct 17 2019

Keywords

Comments

Take the standard counterclockwise square spiral starting at 0, as in A304586, but only write one digit at a time in the cells of the spiral: 0,1,2,3,4,5,6,7,8,9,1,0,1,1,1,2,...
Place a chess knight at cell 0. Move it to the lowest-numbered cell it can attack, and if there is a tie, move it to the cell closest (in Euclidean distance) to the start, and if there is still a tie, move to the left(*).
No cell can be visited more than once.
Inspired by the Trapped Knight video and A316667.
Just as for A316667, the sequence is finite. After a while, the knight has no unvisited squares it can reach, and the sequence ends with a(1217) = 4.
(*)Moving to the left means choose the point with the lowest x-coordinate. This leads to an unambiguous choice of tied squares only for the 'move left' case.

Examples

			The digit-square spiral is
                                .
                                .
    2---2---2---1---2---0---2   2
    |                       |   |
    3   1---2---1---1---1   9   3
    |   |               |   |   |
    2   3   4---3---2   0   1   1
    |   |   |       |   |   |   |
    4   1   5   0---1   1   8   3
    |   |   |           |   |   |
    2   4   6---7---8---9   1   0
    |   |                   |   |
    5   1---5---1---6---1---7   3
    |                           |
    2---6---2---7---2---8---2---9
		

Crossrefs

Extensions

More terms from Luca Petrone
Corrected and extended by Eric Angelini, Oct 24 2019

A334742 Pascal's spiral: starting with a(1) = 1, proceed in a square spiral, computing each term as the sum of horizontally and vertically adjacent prior terms.

Original entry on oeis.org

1, 1, 1, 2, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 10, 12, 12, 14, 17, 20, 20, 23, 27, 32, 37, 37, 42, 48, 55, 62, 62, 69, 77, 87, 99, 111, 111, 123, 137, 154, 174, 194, 194, 214, 237, 264, 296, 333, 370, 370, 407, 449, 497, 552, 614, 676, 676, 738, 807, 884, 971, 1070
Offset: 1

Views

Author

Alec Jones and Peter Kagey, May 09 2020

Keywords

Comments

This is the square spiral analogy of Pascal's triangle thought of as a table read by antidiagonals.

Examples

			Spiral begins:
  111--99--87--77--69--62
                        |
   12--12--10---8---7  62
    |               |   |
   14   2---2---1   7  55
    |   |       |   |   |
   17   3   1---1   6  48
    |   |           |   |
   20   3---4---5---5  42
    |                   |
   20--23--27--32--37--37
a(15) = 10 = 8 + 2, the sum of the cells immediately to the right and below. The term to the left is not included in the sum because it has not yet occurred in the spiral.
		

Crossrefs

x- and y-coordinates are given by A174344 and A274923, respectively.

Formula

a(A033638(n)) = a(A002620(n)) for n > 1.

A304584 A linear mapping a(n) = x + d*n of pairs of nonnegative integers (x,d), where the pairs are enumerated by antidiagonals.

Original entry on oeis.org

0, 1, 2, 2, 5, 10, 3, 9, 17, 27, 4, 14, 26, 40, 56, 5, 20, 37, 56, 77, 100, 6, 27, 50, 75, 102, 131, 162, 7, 35, 65, 97, 131, 167, 205, 245, 8, 44, 82, 122, 164, 208, 254, 302, 352, 9, 54, 101, 150, 201, 254, 309, 366, 425, 486, 10, 65, 122, 181, 242, 305, 370, 437, 506, 577, 650, 11
Offset: 0

Views

Author

Hugo Pfoertner, May 15 2018

Keywords

Comments

The sequence solves the following riddle, which has been communicated by Klaus Nagel: A flea starts to jump on the nonnegative integers at time = 0 at an unknown location x >= 0 making jumps of unknown, but constant distance d >= 0 at every subsequent time step. By which strategy can the flea be captured with 100% certainty in a finite number of trials? The solution is to hit a(n) at time = n. This works for all enumerations of pairs (x,d) of integers, because eventually any combination of starting location x and jump width d will be addressed.

Examples

			  d:
  5 |  20
  4 |  14  19
  3 |   9  13  18
  2 |   5   8  12  17
  1 |   2   4   7  11  16
  0 |   0   1   3   6  10  15
    |________________________
  x:    0   1   2   3   4   5
.
a(13) = 1 + 13*3 = 40 because the 13th position in the enumeration corresponds to x=1 and d=3.
		

Crossrefs

Programs

  • Maple
    pos2pair:=proc(n) local w,k,e;w:=floor(sqrt(2*n));if w*(w+1)>2*n then k:=w-1;else k:=w;fi;e:=n-k*(k+1)/2;return [k-e,e];end:WhereFlea:=proc(n) local x,d,pair; pair:=pos2pair(n);x:=pair[1];d:=pair[2];return x+d*n;end:
    seq(WhereFlea(n),n=0..66);# Rainer Rosenthal, May 23 2018

A304585 A linear mapping a(n) = x + d*n of pairs of nonnegative integers (x,d), where the pairs are enumerated by meandering antidiagonals.

Original entry on oeis.org

0, 1, 2, 6, 5, 2, 3, 9, 17, 27, 40, 34, 26, 16, 4, 5, 20, 37, 56, 77, 100, 126, 111, 94, 75, 54, 31, 6, 7, 35, 65, 97, 131, 167, 205, 245, 288, 260, 230, 198, 164, 128, 90, 50, 8, 9, 54, 101, 150, 201, 254, 309, 366, 425, 486, 550, 505, 458, 409, 358, 305, 250, 193, 134, 73, 10, 11
Offset: 0

Views

Author

Hugo Pfoertner, May 16 2018

Keywords

Comments

The sequence is an alternative solution to the riddle described in the comments of A304584.

Examples

			  d:
  5 |  20
  4 |  10  19
  3 |   9  11  18
  2 |   3   8  12  17
  1 |   2   4   7  13  16
  0 |   0   1   5   6  14  15
    |________________________
  x:    0   1   2   3   4   5
.
a(13)= 3 + 13*1 = 16 because the 13th position in the enumeration corresponds to x=3 and d=1.
		

Crossrefs

Programs

  • Maple
    pos2pM:=proc(n) local w,k,e;w:=floor(sqrt(2*n));if w*(w+1)>2*n then k:=w-1;else k:=w;fi;e:=n-k*(k+1)/2;if modp(k,2)=1 then return [k-e,e];else return [e,k-e];fi end: WhereFlea:=proc(n) local x,d,pair; pair:=pos2pM(n);x:=pair[1];d:=pair[2];return x+d*n;end: seq(WhereFlea(n),n=0..66); # Rainer Rosenthal, May 23 2018

A304587 A linear mapping a(n) = x + d*n of pairs of integers (x,d), where the pairs are enumerated by a number spiral along antidiagonals.

Original entry on oeis.org

0, 1, 2, -1, -4, 2, 7, 14, 7, -2, -11, -22, -11, 3, 16, 31, 48, 33, 16, -3, -22, -43, -66, -45, -22, 4, 29, 56, 85, 116, 89, 60, 29, -4, -37, -72, -109, -148, -113, -76, -37, 5, 46, 89, 134, 181, 230, 187, 142, 95, 46, -5, -56, -109, -164, -221, -280, -227, -172, -115, -56, 6, 67
Offset: 0

Views

Author

Hugo Pfoertner, May 16 2018

Keywords

Comments

The sequence is an alternative solution to the riddle described in the comments of A304584 without the restriction of x and d to nonnegative numbers.

Examples

			   d:
   3 |              16  28
     |             /   \   \
   2 |          17   7  15  27
     |         /   /   \   \   \
   1 |      18   8   2   6  14  26
     |     /   /   /   \   \   \   \
   0 |  19   9   3   0---1   5  13  25
     |     \   \   \    --> --> -->
  -1 |      20  10   4  12  24
     |         \   \  /   /
  -2 |          21  11  23
     |             \   /
  -3 |              22
    __________________________________
  x:    -3  -2  -1   0   1   2   3   4
.
a(10) = -1 + 10*(-1) = -11 because the 10th position in the spiral corresponds to x = -1 and d = -1,
a(15) = 1 + 15*2 = 31 because the 15th position in the spiral corresponds to x = 1 and d = 2,
a(25) = 4 + 25*0 = 4 because the 25th position in the spiral corresponds to x = 4 and d = 0.
		

Crossrefs

Cf. A001844 (where the spiral jumps to next ring), A304584, A304585, A304586.

Programs

  • Maple
    n2left := proc(n)local w,k;return floor(sqrt((n-1)/2));end:pos2pH:=proc(n)local k,q,Q,e,E,sp;k:=n2left(n);q:=2*k^2+1;Q:=2*(k+1)^2+1;e:=n-q;E:=Q-n;if n<2 then return[n,0];fi;if e<=k then return[-k+e,-e];elif e<2*k then return[-k+e,-2*k+e];elif E<=k+1 then return[-(k+1)+E,E];else return[E-(k+1),2*(k+1)-E];fi;end:WhereFlea:=proc(n) local x,d,pair; pair:=pos2pH(n);x:=pair[1];d:=pair[2];return x+d*n;end: seq(WhereFlea(n),n=0..62);# Rainer Rosenthal, May 28 2018
  • Sage
    def a(n):
        if n<2: return n
        k = isqrt((n-1)/2)
        e = n-k*(2*k+1)-1
        x = e if ePeter Luschny, May 29 2018

Extensions

a(1) corrected by Rainer Rosenthal, May 28 2018

A334741 Fill an infinite square array by following a spiral around the origin; in the central cell enter a(0)=1; thereafter, in the n-th cell, enter the sum of the entries of those earlier cells that are in the same row or column as that cell.

Original entry on oeis.org

1, 1, 1, 2, 3, 5, 8, 11, 21, 40, 47, 93, 180, 203, 397, 796, 1576, 1675, 3305, 6636, 13192, 14004, 27607, 55029, 110192, 220024, 226740, 450123, 898661, 1798700, 3594248, 3704800, 7354303, 14681369, 29349536, 58710640, 117394896, 119196748, 237492079
Offset: 0

Views

Author

Alec Jones and Peter Kagey, May 09 2020

Keywords

Comments

The spiral track being used here is the same as in A274640, except that the starting cell here is indexed 0 (as in A274641).
The central cell gets index 0 (and we fill it in with the value a(0)=1).

Examples

			Spiral begins:
     3----2----1
     |         |
     5    1----1   47
     |              |
     8---11---21---40
a(11) = 47 = 1 + 1 + 5 + 40, the sum of the cells in its row and column.
		

Crossrefs

Cf. A280027.
x- and y-coordinates are given by A174344 and A274923, respectively.

Programs

  • PARI
    \\ here P(n) returns A174344 and A274923 as pair.
    P(n)={my(m=sqrtint(n), k=ceil(m/2)); n -= 4*k^2; if(n<0, if(n<-m, [k, 3*k+n], [-k-n, k]), if(nAndrew Howroyd, May 09 2020
Showing 1-6 of 6 results.