A056944 Amount by which used area of rectangle needed to enclose a non-touching spiral of length n on a square lattice exceeds unused area.
0, 1, 2, 2, 2, 4, 3, 2, 4, 6, 4, 2, 4, 6, 8, 5, 2, 4, 6, 8, 10, 6, 2, 4, 6, 8, 10, 12, 7, 2, 4, 6, 8, 10, 12, 14, 8, 2, 4, 6, 8, 10, 12, 14, 16, 9, 2, 4, 6, 8, 10, 12, 14, 16, 18, 10, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 11, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 12, 2, 4, 6, 8, 10, 12, 14, 16
Offset: 0
Examples
a(9)=6 since spiral is as marked by 9 X's in 4*3 = 12 rectangle, with 12-9 = 3 spaces unused and a used-unused difference of 9-3 = 6: X.XX X..X XXXX As a triangle, the first few rows are: 1; 2, 2; 2, 4, 3; 2, 4, 6, 4; 2, 4, 6, 8, 5; 2, 4, 6, 8, 10, 6; 2, 4, 6, 8, 10, 12, 7; ... (= reversal of triangle A143595). Row sums = n^2. - _Gary W. Adamson_, Aug 26 2008
Links
- Vincenzo Librandi, Table of n, a(n) for n = 0..1000
Programs
-
Magma
[2*n-Floor((Sqrt(8*n+1)-1)/2)*Ceiling((Sqrt(8*n+1)-1)/2): n in [0..90]]; // Vincenzo Librandi, Aug 06 2017
-
Mathematica
uar[n_]:=Module[{c=(Sqrt[8n+1]-1)/2},2n-Floor[c]Ceiling[c]]; Array[uar,90,0] (* Harvey P. Dale, Aug 14 2013 *)
-
Python
from math import isqrt def A056944(n): return (n<<1)-(isqrt(n<<3)+1>>1)*((k:=isqrt(m:=n+1<<1))-((m>=k*(k+1)+1)^1)) # Chai Wah Wu, Jun 10 2025
Comments