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.

This page as a plain text file.
%I A304587 #22 Nov 09 2018 18:27:08
%S A304587 0,1,2,-1,-4,2,7,14,7,-2,-11,-22,-11,3,16,31,48,33,16,-3,-22,-43,-66,
%T A304587 -45,-22,4,29,56,85,116,89,60,29,-4,-37,-72,-109,-148,-113,-76,-37,5,
%U A304587 46,89,134,181,230,187,142,95,46,-5,-56,-109,-164,-221,-280,-227,-172,-115,-56,6,67
%N 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.
%C A304587 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.
%H A304587 Rainer Rosenthal, <a href="/A304587/b304587.txt">Table of n, a(n) for n = 0..10000</a>
%e A304587    d:
%e A304587    3 |              16  28
%e A304587      |             /   \   \
%e A304587    2 |          17   7  15  27
%e A304587      |         /   /   \   \   \
%e A304587    1 |      18   8   2   6  14  26
%e A304587      |     /   /   /   \   \   \   \
%e A304587    0 |  19   9   3   0---1   5  13  25
%e A304587      |     \   \   \    --> --> -->
%e A304587   -1 |      20  10   4  12  24
%e A304587      |         \   \  /   /
%e A304587   -2 |          21  11  23
%e A304587      |             \   /
%e A304587   -3 |              22
%e A304587     __________________________________
%e A304587   x:    -3  -2  -1   0   1   2   3   4
%e A304587 .
%e A304587 a(10) = -1 + 10*(-1) = -11 because the 10th position in the spiral corresponds to x = -1 and d = -1,
%e A304587 a(15) = 1 + 15*2 = 31 because the 15th position in the spiral corresponds to x = 1 and d = 2,
%e A304587 a(25) = 4 + 25*0 = 4 because the 25th position in the spiral corresponds to x = 4 and d = 0.
%p A304587 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
%o A304587 (Sage)
%o A304587 def a(n):
%o A304587     if n<2: return n
%o A304587     k = isqrt((n-1)/2)
%o A304587     e = n-k*(2*k+1)-1
%o A304587     x = e if e<k else k*(2*k+3)-n+2
%o A304587     d = abs(x)-k if e<k else k+1-abs(x)
%o A304587     return x + d*n
%o A304587 print([a(n) for n in range(63)]) # _Peter Luschny_, May 29 2018
%Y A304587 Cf. A001844 (where the spiral jumps to next ring), A304584, A304585, A304586.
%K A304587 sign,look
%O A304587 0,3
%A A304587 _Hugo Pfoertner_, May 16 2018
%E A304587 a(1) corrected by _Rainer Rosenthal_, May 28 2018