A090925 Permutation of natural numbers arising from a square spiral.
1, 4, 5, 6, 7, 8, 9, 2, 3, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 10, 11, 12, 13, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 26, 27, 28, 29, 30, 31, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80
Offset: 1
Links
- Eric M. Schmidt, Table of n, a(n) for n = 1..1000
Programs
-
Mathematica
With[{x = Floor[(Floor[Sqrt[n-1]]+1)/2]}, Table[If[n+2*x <= (2*x+1)^2, n +2*x, n-6*x], {n, 1, 75}]] (* G. C. Greubel, Feb 05 2019 *)
-
PARI
{s(n) = ((sqrtint(n-1)+1)/2)\1}; for(n=1,75, print1(if(n+2*s(n) <= (2*s(n)+1)^2, n +2*s(n), n - 6*s(n)), ", ")) \\ G. C. Greubel, Feb 05 2019
-
Sage
def a(n): x = (isqrt(n-1)+1)//2 return n + 2*x if n + 2*x <= (2*x+1)^2 else n - 6*x [a(n) for n in (1..75)] # Eric M. Schmidt, May 18 2016
Extensions
Offset corrected by Eric M. Schmidt, May 18 2016
Comments