login
A365582
a(n) is the number at the third vertex of an equilateral triangle whose first and second vertices are at the numbers 1 and n, respectively, on a triangular array of integers.
0
1, 0, 2, -1, 1, 4, -2, 0, 3, 7, -3, -1, 2, 6, 11, -4, -2, 1, 5, 10, 16, -5, -3, 0, 4, 9, 15, 22, -6, -4, -1, 3, 8, 14, 21, 29, -7, -5, -2, 2, 7, 13, 20, 28, 37, -8, -6, -3, 1, 6, 12, 19, 27, 36, 46, -9, -7, -4, 0, 5, 11, 18, 26, 35, 45, 56, -10, -8, -5, -1, 4, 10, 17, 25, 34, 44, 55, 67
OFFSET
1,3
COMMENTS
Given a triangular array of numbers with rows consisting of (1), (2,3), (4,5,6), (7,8,9,10), etc., a(n) is the number at the third vertex of an equilateral triangle with a base leg drawn from 1 to n. This triangle is drawn clockwise from 1 to n to a(n) and back to 1. If the third vertex thus drawn falls outside the original array, the array's rows are regarded as extending beyond its original edges (e.g., the 3rd row, which originally consisted of the numbers 4, 5, and 6, is extended to the left as necessary, so that the number to the left of 4 is 3).
FORMULA
a(n) = (m^4)/8 - (m^3)/4 + ((-4*n - 1)*m^2)/8 + ((4*n - 6)*m)/8 + n^2/2 + n/2 + 1 where m = floor((sqrt(8*n - 7) + 1)/2).
EXAMPLE
Given a triangle of ascending integers:
.
. 1
.
. 2 3
.
. 4 5 6
.
. 7 8 9 10
.
For a value n, the output is defined as the 3rd vertex of an equilateral triangle formed clockwise from the vertices 1 and n.
E.g., for a(6), we begin by marking the 2 vertices', 1 and 6.
.
. [1]
.
. 2 3
.
. 4 5 [6]
.
. 7 8 9 10
.
. [1]
.
. 2 3
.
. (4) 5 [6]
.
. 7 8 9 10
.
. [1]
. / \
. 2 3
. / \
. (4)-----[6]
.
. 7 8 9 10
.
.
a(6) = 4 would make the 3rd vertex of the equilateral triangle formed by 1,6,4.
Additionally, the triangle can be padded with neighboring integers for vertices outside of the triangle.
E.g., for a(9), the original triangular grid, with 1 and 9 marked using brackets, is:
.
. [1]
.
. 2 3
.
. 4 5 6
.
. 7 8 [9] 10
.
which can be extended to:
.
. 0 /[1]\ 2
. / \
. 1 / 2 3 \ 4
. / \
. 3 / 4 5 6 \ 7
. / \
. 6 / 7 8 [9] 10 \11
.
thus the equilateral triangle having 1 and 9 as its first two vertices is completed in the clockwise direction by adding 3.
. 0 [1] 2
.
. 1 2 3 4
.
. (3) 4 5 6 7
.
. 6 7 8 [9] 10 11
.
A skewed equilateral triangle is thus formed with vertices at 1, 9, and 3, so a(9) = 3:
.
. 0 [1] 2
. _/ |
. 1_/ 2 \3 4
. _/ |
. (3)_ 4 5 \ 6 7
. \___ |
. 6 7 8\_[9] 10 11
PROG
(PARI) a(n) = my(m = (sqrtint(n*8)+1)\2); (m^4)/8 - (m^3)/4 + ((-4*n - 1)*m^2)/8 + ((4*n - 6)*m)/8 + n^2/2 + n/2 + 1; \\ Michel Marcus, Sep 27 2023
CROSSREFS
Cf. A002024.
Sequence in context: A187800 A340189 A323873 * A367559 A099020 A179438
KEYWORD
sign
AUTHOR
Robert J. Fortier, Sep 20 2023
STATUS
approved