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.

A220098 Manhattan distances between 2n and 1 in the double spiral with positive integers and 1 at the center.

This page as a plain text file.
%I A220098 #28 Jan 11 2025 18:52:26
%S A220098 1,2,1,2,3,2,3,4,3,2,3,4,5,4,3,4,5,6,5,4,3,4,5,6,7,6,5,4,5,6,7,8,7,6,
%T A220098 5,4,5,6,7,8,9,8,7,6,5,6,7,8,9,10,9,8,7,6,5,6,7,8,9,10,11,10,9,8,7,6,
%U A220098 7,8,9,10,11,12,11,10,9,8,7,6,7,8,9,10,11,12,13
%N A220098 Manhattan distances between 2n and 1 in the double spiral with positive integers and 1 at the center.
%C A220098 Double spiral begins:
%C A220098 .
%C A220098   82---84---86---88---90---92---94---96---98
%C A220098    |
%C A220098   80   51---53---55---57---59---61---63---65
%C A220098    |    |                                  |
%C A220098   78   49   26---28---30---32---34---36   67
%C A220098    |    |    |                        |    |
%C A220098   76   47   24   11---13---15---17   38   69
%C A220098    |    |    |    |              |    |    |
%C A220098   74   45   22    9    2----4   19   40   71
%C A220098    |    |    |    |    |    |    |    |    |
%C A220098   72   43   20    7    1    6   21   42   73
%C A220098    |    |    |    |    |    |    |    |    |
%C A220098   70   41   18    5----3    8   23   44   75
%C A220098    |    |    |              |    |    |    |
%C A220098   68   39   16---14---12---10   25   46   77
%C A220098    |    |                        |    |    |
%C A220098   66   37---35---33---31---29---27   48   79
%C A220098    |                                  |    |
%C A220098   64---62---60---58---56---54---52---50   81
%C A220098                                            |
%C A220098   99---97---95---93---91---89---87---85---83
%F A220098 abs( a(n) - a(n-1) ) = 1.
%F A220098 From _Thomas Scheuerle_, Jan 07 2025: (Start)
%F A220098 a(n*(n+1)/2 - k) = 1 + a(n*(n-1)/2 + k) with a(0) = 0 and for 0 <= k < n.
%F A220098 a(n) = A053615(A128217(n+1)). (End)
%e A220098 From _Philippe Deléham_, Mar 08 2013: (Start)
%e A220098 As a square array, this begins:
%e A220098   1,  1,  2,  2,  3,  3,  4,  4,  5, ...
%e A220098   2,  3,  3,  4,  4,  5,  5,  6,  6, ...
%e A220098   2,  4,  5,  5,  6,  6,  7,  7,  8, ...
%e A220098   3,  4,  6,  7,  7,  8,  8,  9,  9, ...
%e A220098   3,  5,  6,  8,  9,  9, 10, 10, 11, ...
%e A220098   4,  5,  7,  8, 10, 11, 11, 12, 12, ...
%e A220098   4,  6,  7,  9, 10, 12, 13, 13, 14, ...
%e A220098   5,  6,  8,  9, 11, 12, 14, 15, 15, ..., etc.
%e A220098 As a triangle, this begins:
%e A220098   1
%e A220098   2, 1
%e A220098   2, 3, 2
%e A220098   3, 4, 3, 2
%e A220098   3, 4, 5, 4, 3
%e A220098   4, 5, 6, 5, 4, 3, etc. (End)
%o A220098 (C)
%o A220098 #include <stdio.h>
%o A220098 #define SIZE 20
%o A220098 int grid[SIZE][SIZE];
%o A220098 int direction[] = {0, -1,  1, 0, 0, 1, -1, 0};
%o A220098 main() {
%o A220098   int i, j, x1, y1, x2, y2, stepSize;
%o A220098   int direction1pos=0, direction2pos=4, val;
%o A220098   x1 = y1 = x2 = y2 = SIZE/2;
%o A220098   for (val=grid[y1][x1]=1, stepSize=0; ; ++stepSize) {
%o A220098     if (x1<1 || x1>=SIZE-1 || x2<1 || x2>=SIZE-1) break;
%o A220098     if (y1<1 || y1>=SIZE-1 || y2<1 || y2>=SIZE-1) break;
%o A220098     for (i=stepSize|1; i; ++val,--i) {
%o A220098       x1 += direction[direction1pos  ];
%o A220098       y1 += direction[direction1pos+1];
%o A220098       x2 += direction[direction2pos  ];
%o A220098       y2 += direction[direction2pos+1];
%o A220098       grid[y1][x1] = val*2;
%o A220098       grid[y2][x2] = val*2+1;
%o A220098       printf("%d, ",abs(x1-SIZE/2)+abs(y1-SIZE/2));
%o A220098     }
%o A220098     direction1pos = (direction1pos+2) & 7;
%o A220098     direction2pos = (direction2pos+2) & 7;
%o A220098   }
%o A220098   for (i=0; i<SIZE; ++i) {
%o A220098     printf("\n");
%o A220098     for (j=0; j<SIZE; ++j)
%o A220098       printf("%4d ",grid[i][j]);
%o A220098   }
%o A220098 }
%o A220098 (PARI)
%o A220098 step(v, m) = concat(v, vector(m, k, 1+v[#v-k+1]))
%o A220098 a(max_n) = {my(v=[0], k=1); while(#v < max_n+1, v=step(v,k); k++); v[2..max_n+1]} \\ _Thomas Scheuerle_, Jan 07 2025
%o A220098 (PARI)
%o A220098 A053615(n) = if(n<1, 0, sqrtint(n) - A053615(n - sqrtint(n)))
%o A220098 a(n) = A053615(floor( floor( (sqrtint(n*8) + 1)/2 )^2/2 ) + n) \\ _Thomas Scheuerle_, Jan 07 2025
%Y A220098 Cf. A053615, A077043, A128217, A214526.
%K A220098 nonn,easy
%O A220098 1,2
%A A220098 _Alex Ratushnyak_, Dec 04 2012