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.

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