login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
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. 5

%I #22 Nov 09 2018 18:27:08

%S 0,1,2,-1,-4,2,7,14,7,-2,-11,-22,-11,3,16,31,48,33,16,-3,-22,-43,-66,

%T -45,-22,4,29,56,85,116,89,60,29,-4,-37,-72,-109,-148,-113,-76,-37,5,

%U 46,89,134,181,230,187,142,95,46,-5,-56,-109,-164,-221,-280,-227,-172,-115,-56,6,67

%N 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 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 Rainer Rosenthal, <a href="/A304587/b304587.txt">Table of n, a(n) for n = 0..10000</a>

%e d:

%e 3 | 16 28

%e | / \ \

%e 2 | 17 7 15 27

%e | / / \ \ \

%e 1 | 18 8 2 6 14 26

%e | / / / \ \ \ \

%e 0 | 19 9 3 0---1 5 13 25

%e | \ \ \ --> --> -->

%e -1 | 20 10 4 12 24

%e | \ \ / /

%e -2 | 21 11 23

%e | \ /

%e -3 | 22

%e __________________________________

%e x: -3 -2 -1 0 1 2 3 4

%e .

%e a(10) = -1 + 10*(-1) = -11 because the 10th position in the spiral corresponds to x = -1 and d = -1,

%e a(15) = 1 + 15*2 = 31 because the 15th position in the spiral corresponds to x = 1 and d = 2,

%e a(25) = 4 + 25*0 = 4 because the 25th position in the spiral corresponds to x = 4 and d = 0.

%p 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 (Sage)

%o def a(n):

%o if n<2: return n

%o k = isqrt((n-1)/2)

%o e = n-k*(2*k+1)-1

%o x = e if e<k else k*(2*k+3)-n+2

%o d = abs(x)-k if e<k else k+1-abs(x)

%o return x + d*n

%o print([a(n) for n in range(63)]) # _Peter Luschny_, May 29 2018

%Y Cf. A001844 (where the spiral jumps to next ring), A304584, A304585, A304586.

%K sign,look

%O 0,3

%A _Hugo Pfoertner_, May 16 2018

%E a(1) corrected by _Rainer Rosenthal_, May 28 2018

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 25 01:35 EDT 2024. Contains 371964 sequences. (Running on oeis4.)