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.

A232113 a(n) is the Manhattan distance between n and 2*n in a square spiral of positive integers with 1 at the center.

Original entry on oeis.org

1, 2, 3, 2, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 3, 4, 3, 2, 3, 2, 1, 2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 6, 5, 6, 7, 8, 7, 8, 9, 10, 11, 8, 11, 12, 13, 12, 9, 10, 13, 16, 15, 12, 9, 12, 15, 16, 15, 12, 9, 12, 15, 14, 13, 12, 11, 12, 13, 12, 11, 10, 9, 10, 11, 10, 9, 8, 7, 8, 9
Offset: 1

Views

Author

Alex Ratushnyak, Nov 19 2013

Keywords

Comments

Spiral begins:
.
49 26--27--28--29--30--31
| | |
48 25 10--11--12--13 32
| | | | |
47 24 9 2---3 14 33
| | | | | | |
46 23 8 1 4 15 34
| | | | | |
45 22 7---6---5 16 35
| | | |
44 21--20--19--18--17 36
| |
43--42--41--40--39--38--37
.
Numbers n such that a(n)^2=n: 1, 4, 16, 625, 20736, 707281, 24010000, 815730721, ...; that is, 1, 4, 2^4, 5^4, 12^4, 29^4, 70^4, 169^4, ... (cf. Pell numbers: A000129).

Crossrefs

A236345 a(n) is the Manhattan distance between n and n^2 in a left-aligned triangle with next M natural numbers in row M: 1, 2 3, 4 5 6, 7 8 9 10, etc.

Original entry on oeis.org

0, 1, 3, 3, 6, 10, 9, 14, 9, 15, 11, 18, 26, 17, 26, 19, 29, 40, 27, 39, 24, 42, 27, 39, 54, 35, 51, 36, 53, 71, 48, 67, 42, 62, 83, 56, 85, 56, 79, 48, 72, 97, 64, 90, 55, 90, 118, 81, 110, 71, 101, 68, 91, 123, 80, 122, 77, 111, 146, 99, 135, 86, 123, 88, 110
Offset: 1

Views

Author

Alex Ratushnyak, Jan 23 2014

Keywords

Examples

			The triangle where we measure distances begins as (cf. A000027 drawn as a lower or upper right triangle):
   1
   2  3
   4  5  6
   7  8  9 10
  11 12 13 14 15
  16 17 18 19 20 21
  22 23 24 25 26 27 28
  29 30 31 32 33 34 35 36
  37 38 39 40 41 42 43 44 45
Manhattan distance between 5 and 25 in this triangle is 4+2=6, thus a(5)=6.
		

Crossrefs

Programs

  • Python
    import math
    def getXY(n):
      y = int(math.sqrt(n*2))
      if n<=y*(y+1)//2: y-=1
      x = n - y*(y+1)//2
      return x, y
    for n in range(1,77):
      ox, oy = getXY(n)
      nx, ny = getXY(n*n)
      print(str(abs(nx-ox)+abs(ny-oy)), end=',')
    
  • Python
    from math import isqrt, comb
    def A236345(n): return (isqrt(n**2<<3)+1>>1)-(isqrt(n<<3)+1>>1)+abs(n*(n-1)-comb((m2:=isqrt(k2:=n**2<<1))+(k2>m2*(m2+1)),2)+comb((m:=isqrt(k:=n<<1))+(k>m*(m+1)),2)) # Chai Wah Wu, Jun 07 2025
    
  • Scheme
    (define (A236345 n) (+ (- (A002024 (A000290 n)) (A002024 n)) (abs (- (A002260 (A000290 n)) (A002260 n))))) ;; Antti Karttunen, Jan 25 2014

Formula

a(n) = (A002024(n^2)-A002024(n)) + |A002260(n^2)-A002260(n)|. [Where |x| stands for the absolute value. This formula can be probably reduced further.] - Antti Karttunen, Jan 25 2014

A232115 a(n) is the Manhattan distance between n and n(n+1)/2 in a square spiral of positive integers with 1 at the center.

Original entry on oeis.org

0, 1, 3, 4, 2, 3, 5, 6, 4, 5, 9, 6, 6, 7, 11, 8, 8, 15, 9, 10, 10, 13, 11, 12, 22, 11, 15, 18, 12, 15, 17, 22, 12, 21, 25, 10, 26, 21, 19, 18, 24, 27, 15, 34, 24, 21, 31, 20, 28, 21, 31, 24, 28, 41, 19, 36, 36, 23, 35, 26, 38, 23, 41, 36, 28, 53, 29, 38, 40, 31, 39
Offset: 1

Views

Author

Alex Ratushnyak, Nov 19 2013

Keywords

Comments

Spiral begins:
.
49 26--27--28--29--30--31
| | |
48 25 10--11--12--13 32
| | | | |
47 24 9 2---3 14 33
| | | | | | |
46 23 8 1 4 15 34
| | | | | |
45 22 7---6---5 16 35
| | | |
44 21--20--19--18--17 36
| |
43--42--41--40--39--38--37
.
Numbers n such that a(n)*2=n: 2, 6, 10, 12, 14, 16, 20, 24, 30, 80, 192, 198, 350, 524, 536, 548, 552, 560, 564, 576, 588, 594, 606, 618, 630, 1380, 1900, 4446, ...

Crossrefs

Programs

  • Python
    import math
    def get_x_y(n):
      sr = math.isqrt(n-1)
      sr = sr-1+(sr&1)
      rm = n-sr*sr
      d = (sr+1)//2
      if rm<=sr+1:
         return -d+rm,d
      if rm<=sr*2+2:
         return d,d-(rm-(sr+1))
      if rm<=sr*3+3:
         return d-(rm-(sr*2+2)),-d
      return -d,-d+rm-(sr*3+3)
    for n in range(1,333):
      x0,y0 = get_x_y(n)
      x1,y1 = get_x_y(n*(n+1)//2)
      print(abs(x1-x0)+abs(y1-y0), end=', ')

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.

Original entry on oeis.org

1, 3, 11, 15, 13, 9, 5, 21, 33, 59, 71, 49, 47, 35, 15, 13, 43, 73, 109, 123, 117, 109, 167, 141, 113, 77, 43, 5, 51, 95, 145, 201, 263, 281, 397, 413, 317, 333, 269, 239, 183, 121, 63, 11, 81, 147, 219, 307, 379, 471, 567, 623, 517, 569, 683, 503, 545, 473, 395, 311
Offset: 1

Views

Author

Alex Ratushnyak, Jan 16 2014

Keywords

Comments

Spiral begins:
.
49 26--27--28--29--30--31
| | |
48 25 10--11--12--13 32
| | | | |
47 24 9 2---3 14 33
| | | | | | |
46 23 8 1 4 15 34
| | | | | |
45 22 7---6---5 16 35
| | | |
44 21--20--19--18--17 36
| |
43--42--41--40--39--38--37

Examples

			Manhattan distance between 2^3=8 and 3^3=27 is 3 in a square spiral, so a(2)=3.
		

Crossrefs

Programs

  • Python
    import math
    def get_x_y(n):
      sr = int(math.sqrt(n-1))  # Ok for small n's
      sr = sr-1+(sr&1)
      rm = n-sr*sr
      d = (sr+1)//2
      if rm<=sr+1:
         return -d+rm, d
      if rm<=sr*2+2:
         return d, d-(rm-(sr+1))
      if rm<=sr*3+3:
         return d-(rm-(sr*2+2)), -d
      return -d, -d+rm-(sr*3+3)
    for n in range(1, 77):
      x0, y0 = get_x_y(n**3)
      x1, y1 = get_x_y((n+1)**3)
      print(abs(x1-x0)+abs(y1-y0), end=', ')
Showing 1-4 of 4 results.