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!)
A090929 Permutation of natural numbers arising from a square spiral. 6

%I #17 Jul 05 2022 11:13:49

%S 1,8,9,2,3,4,5,6,7,22,23,24,25,10,11,12,13,14,15,16,17,18,19,20,21,44,

%T 45,46,47,48,49,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,

%U 74,75,76,77,78,79,80,81,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64

%N Permutation of natural numbers arising from a square spiral.

%C Write out the natural numbers in a square counterclockwise spiral:

%C .

%C 17--16--15--14--13

%C | |

%C 18 5---4---3 12

%C | | | |

%C 19 6 1---2 11

%C | | |

%C 20 7---8---9--10

%C |

%C 21--22--23--24--25

%C .

%C Now read off the numbers in a counterclockwise spiral: 1 -> 8 -> 9 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 22 -> etc.

%H Eric M. Schmidt, <a href="/A090929/b090929.txt">Table of n, a(n) for n = 1..1000</a>

%t With[{x = Floor[(Floor[Sqrt[n-1]] +1)/2]}, Table[If[n +6*x <= (2*x+1)^2, n +6*x, n -2*x], {n, 1, 75}]] (* _G. C. Greubel_, Feb 05 2019 *)

%o (Sage)

%o def a(n):

%o x = (isqrt(n-1)+1)//2

%o return n + 6*x if n + 6*x <= (2*x+1)^2 else n - 2*x

%o [a(n) for n in (1..75)]

%o # _Eric M. Schmidt_, May 18 2016

%o (PARI) {s(n) = ((sqrtint(n-1)+1)/2)\1};

%o for(n=1,75, print1(if(n+6*s(n) <= (2*s(n)+1)^2, n +6*s(n), n - 2*s(n)), ", ")) \\ _G. C. Greubel_, Feb 05 2019

%Y Cf. A020703, A090861, A090915, A090925, A090928, A090930.

%K easy,nonn

%O 1,2

%A _Felix Tubiana_, Feb 26 2004

%E Offset corrected by _Eric M. Schmidt_, May 18 2016

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 06:14 EDT 2024. Contains 371964 sequences. (Running on oeis4.)