%I #25 Sep 22 2023 23:30:31
%S 1,5,8,16,21,26,38,45,52,59,75,84,93,102,111,131,142,153,164,175,186,
%T 210,223,236,249,262,275,288,316,331,346,361,376,391,406,421,453,470,
%U 487,504,521,538,555,572,589,625,644,663,682,701,720,739,758,777,796,836
%N a(n) = number of visible diamonds (squares rotated by 45 degrees) with diagonal 2 in the large square bounded by the parabola y=x^2 and starting from the point (0, 2n).
%H Anatoliy A. Abramov, <a href="/A365316/a365316.jpg">Squares and parabola visualization</a>.
%F a(n) = f(n) + a(n - 1), where f(n) = Sum_{i=size(n-1)..size(n)} 2*i - 1 and size(n) = floor((1 + sqrt(1 + 8*n) / 2).
%e Illustration for n = 0..3:
%e . _____________________________
%e /\ ^
%e / \ |
%e /\ d/\ |
%e / \/ \ |
%e /\ d/\ d/\ vertical |
%e / \/ \/ \ limits |
%e \ d/\ d/\ d/ of large |
%e \/ \/ \/____________ square D |
%e \ d/\ d/ ^ |
%e \/ \/ vertical | |
%e /\ c/\ limits | |
%e / \/ \ _ _ of _ _|____________v_
%e \ c/\ c/ large | ^
%e \/ \/ square C | |
%e /\ b/\ | vertical |
%e / \/ \ __________v_ limits |
%e \ b/\ b/ of large |
%e \/ \/ square B |
%e \ b/ |
%e \/___________________________v_
%e /\ limits ^
%e / \ of large |
%e \ a/ square A |
%e \/______________v_
%e .
%e n=0: Large square A builds from its bottom vertex at (0, 0), has diagonal size 1*2 = 2 with lateral vertices at (-1, 1) and (1, 1), and is bounded by the parabola at (-1, 1) and (1, 1). It coincides with the 1 small square a. We have 1 small square thus far, so a(0) = 1.
%e n=1: Large square B builds from its bottom vertex at (0, 2), has diagonal size 2*2 = 4 with lateral vertices at (-2, 4) and (2, 4), and is bounded by the parabola at (-2, 2) and (2, 2). It contains the 4 small squares b. The total number of small squares thus far is a(1) = 1 + 4 = 5.
%e n=2: Large square C builds from its bottom vertex at (0, 4), has diagonal size 2*2 = 4 with lateral vertices at (-2, 6) and (2, 6), and is bounded by the parabola at (-2, sqrt(6)) and (2, sqrt(6)). It contains the 3 small squares c as well as the topmost small square b (which has already been counted). The total number of small squares thus far is a(2) = 1 + 4 + 3 = 8.
%e n=3: Large square D builds from its bottom vertex at (0, 6), has diagonal size 3*2 = 6 with lateral vertices at (-3, 9) and (3, 9), and is bounded by the parabola at (-3, 9) and (3, 9). It contains the 8 small squares d as well as the topmost small square c (which has already been counted). The total number of small squares thus far is a(3) = 1 + 4 + 3 + 8 = 16.
%o (Java)
%o import java.util.stream.IntStream;
%o public class Main {
%o public static void main(String[] args) {
%o IntStream.rangeClosed(0, 100).forEach(it -> System.out.printf("%d, ", sumAllVisibleSquare(it)));
%o }
%o private static int maxSquareSize(int n) {
%o return (int) Math.floor((1 + Math.sqrt(1 + 8 * n)) / 2);
%o }
%o private static int sumVisibleSquares(int n) {
%o int upSquareSize = maxSquareSize(n);
%o int lowSquareSize = maxSquareSize(n - 1);
%o return IntStream.rangeClosed(lowSquareSize, upSquareSize).map(it -> it + (it - 1)).sum();
%o }
%o private static int sumAllVisibleSquare(int n) {
%o return n == 0 ? 1 : sumVisibleSquares(n) + sumAllVisibleSquare(n - 1);
%o }
%o }
%K nonn
%O 0,2
%A _Anatoliy A. Abramov_, Sep 01 2023