[go: up one dir, main page]

login
A365316
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).
1
1, 5, 8, 16, 21, 26, 38, 45, 52, 59, 75, 84, 93, 102, 111, 131, 142, 153, 164, 175, 186, 210, 223, 236, 249, 262, 275, 288, 316, 331, 346, 361, 376, 391, 406, 421, 453, 470, 487, 504, 521, 538, 555, 572, 589, 625, 644, 663, 682, 701, 720, 739, 758, 777, 796, 836
OFFSET
0,2
FORMULA
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).
EXAMPLE
Illustration for n = 0..3:
. _____________________________
/\ ^
/ \ |
/\ d/\ |
/ \/ \ |
/\ d/\ d/\ vertical |
/ \/ \/ \ limits |
\ d/\ d/\ d/ of large |
\/ \/ \/____________ square D |
\ d/\ d/ ^ |
\/ \/ vertical | |
/\ c/\ limits | |
/ \/ \ _ _ of _ _|____________v_
\ c/\ c/ large | ^
\/ \/ square C | |
/\ b/\ | vertical |
/ \/ \ __________v_ limits |
\ b/\ b/ of large |
\/ \/ square B |
\ b/ |
\/___________________________v_
/\ limits ^
/ \ of large |
\ a/ square A |
\/______________v_
.
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.
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.
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.
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.
PROG
(Java)
import java.util.stream.IntStream;
public class Main {
public static void main(String[] args) {
IntStream.rangeClosed(0, 100).forEach(it -> System.out.printf("%d, ", sumAllVisibleSquare(it)));
}
private static int maxSquareSize(int n) {
return (int) Math.floor((1 + Math.sqrt(1 + 8 * n)) / 2);
}
private static int sumVisibleSquares(int n) {
int upSquareSize = maxSquareSize(n);
int lowSquareSize = maxSquareSize(n - 1);
return IntStream.rangeClosed(lowSquareSize, upSquareSize).map(it -> it + (it - 1)).sum();
}
private static int sumAllVisibleSquare(int n) {
return n == 0 ? 1 : sumVisibleSquares(n) + sumAllVisibleSquare(n - 1);
}
}
CROSSREFS
Sequence in context: A314564 A314565 A126695 * A001082 A242090 A030006
KEYWORD
nonn
AUTHOR
Anatoliy A. Abramov, Sep 01 2023
STATUS
approved