A227790 Difference between 3n^2 and the nearest square number.
1, 3, 2, 1, 6, 8, 3, 4, 13, 11, 2, 9, 22, 12, 1, 16, 26, 11, 6, 25, 27, 8, 13, 36, 26, 3, 22, 48, 23, 4, 33, 47, 18, 13, 46, 44, 11, 24, 61, 39, 2, 37, 71, 32, 9, 52, 66, 23, 22, 69, 59, 12, 37, 88, 50, 1, 54, 92, 39, 16, 73, 83, 26, 33, 94, 72, 11, 52, 117, 59, 6, 73, 111, 44, 25, 96, 98, 27, 46, 121
Offset: 1
Keywords
Examples
a(9) = 13 because the difference between 3*9^2 = 243 and the nearest square number (256) is 13.
Programs
-
PARI
a(n)=min(3*n^2-(floor(n*sqrt(3)))^2,(1+floor(n*sqrt(3)))^2-3*n^2)
Comments