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.

A235913 a(n) is the Manhattan distance between n^3 and (n+1)^3 in a square spiral of positive integers with 1 at the center.

This page as a plain text file.
%I A235913 #15 Jan 03 2025 18:39:12
%S A235913 1,3,11,15,13,9,5,21,33,59,71,49,47,35,15,13,43,73,109,123,117,109,
%T A235913 167,141,113,77,43,5,51,95,145,201,263,281,397,413,317,333,269,239,
%U A235913 183,121,63,11,81,147,219,307,379,471,567,623,517,569,683,503,545,473,395,311
%N A235913 a(n) is the Manhattan distance between n^3 and (n+1)^3 in a square spiral of positive integers with 1 at the center.
%C A235913 Spiral begins:
%C A235913 .
%C A235913   49  26--27--28--29--30--31
%C A235913    |   |                   |
%C A235913   48  25  10--11--12--13  32
%C A235913    |   |   |           |   |
%C A235913   47  24   9   2---3  14  33
%C A235913    |   |   |   |   |   |   |
%C A235913   46  23   8   1   4  15  34
%C A235913    |   |   |       |   |   |
%C A235913   45  22   7---6---5  16  35
%C A235913    |   |               |   |
%C A235913   44  21--20--19--18--17  36
%C A235913    |                       |
%C A235913   43--42--41--40--39--38--37
%e A235913 Manhattan distance between 2^3=8 and 3^3=27 is 3 in a square spiral, so a(2)=3.
%o A235913 (Python)
%o A235913 import math
%o A235913 def get_x_y(n):
%o A235913   sr = int(math.sqrt(n-1))  # Ok for small n's
%o A235913   sr = sr-1+(sr&1)
%o A235913   rm = n-sr*sr
%o A235913   d = (sr+1)//2
%o A235913   if rm<=sr+1:
%o A235913      return -d+rm, d
%o A235913   if rm<=sr*2+2:
%o A235913      return d, d-(rm-(sr+1))
%o A235913   if rm<=sr*3+3:
%o A235913      return d-(rm-(sr*2+2)), -d
%o A235913   return -d, -d+rm-(sr*3+3)
%o A235913 for n in range(1, 77):
%o A235913   x0, y0 = get_x_y(n**3)
%o A235913   x1, y1 = get_x_y((n+1)**3)
%o A235913   print(abs(x1-x0)+abs(y1-y0), end=', ')
%Y A235913 Cf. A214526, A232113, A232114, A232115.
%K A235913 nonn
%O A235913 1,2
%A A235913 _Alex Ratushnyak_, Jan 16 2014