a(n) is the number of points with integer coordinates that are inside an equilateral triangle inscribed in a circle of radius n, the location of the triangle in the Oxy coordinate plane is described in the comments.
(history;
published version)
Discussion
Wed May 31
09:33
Stefano Spezia: Made changes in Mathematica according to the last changes in the formula
MATHEMATICA
a[n_]:=Floor[(3n-2+Mod[n, 2])/2]+2Sum[Floor[(3n+Mod[n, 2])/2-Sqrt[3]k], {k, Floor[Sqrt[3]n/2]}]; Array[a, 53] (* Stefano Spezia, May 08 2023 *)
Discussion
Tue May 09
02:58
Kevin Ryde: On the crossrefs front, A194106 might be the sum of floors part (or its friend A183143 going horizontal).
06:13
Nicolay Avilov: Thanks Kevin for the tips and edits.
I don't mind if you make changes and call the triangle a centroid, because it really is.
FORMULA
a(n) = (3*n - 2)/2 + 2*Sum_{k=1..floor((sqrt(3)*n/2)} floor(-sqrt(3)*k + 3*n/2) if n is even;
a(n) = (3*n - 1)/2 + 2*Sum_{k=1..floor((sqrt(3)*n/2)} floor(-sqrt(3)*k + (3*n + 1)/2) if n is odd.
Discussion
Tue May 09
02:47
Kevin Ryde: Stray extra parens. Maybe cases be unified by horizontal stripes, umm, sum 2*floor(k/sqrt3) + 1.
02:48
Kevin Ryde: Triangle position might fit in the name: centroid at the origin and one vertex on the y axis at y=n. (If that's right!)
02:51
Kevin Ryde: Positioning vertex at the origin could suit "horizontal" sum. In any case if k in formula is x (or y or something) then it could be named that.
Discussion
Tue May 09
02:07
Nicolay Avilov: You are right, floor in two places of the formula can be removed. I already did that, thanks for the tip.
FORMULA
a(n) = floor(3*n - 2)/2 + 2*Sum_{k=1..floor((sqrt(3)*n/2)} floor(-sqrt(3)*k + 3*n/2) if n is even;
a(n) = floor(3*n - 1)/2 + 2*Sum_{k=1..floor((sqrt(3)*n/2)} floor(-sqrt(3)*k + (3*n + 1)/2) if n is odd.
Discussion
Mon May 08
16:11
Andrew Howroyd: The formula needs some optimizations to remove trivialities. Since n is an integer then so is 3*n-2, so it unnecessary to talk about floor(3*n - 2) - unless that is not what you intended?
16:24
Nicolay Avilov: Andrew, in the 3*n-2 formula, you still need to divide by 2, and the result will not always be an integer, so I use floor.
17:01
Michel Marcus: then it should be a(n) = floor((3*n - 2)/2)