login
a(n) is equal to the number of cells in one octant of the octagon of unit squares with side equal n.
1

%I #59 Oct 16 2023 06:08:17

%S 1,2,8,11,22,27,43,50,71,80,106,117,148,161,197,212,253,270,316,335,

%T 386,407,463,486,547,572,638,665,736,765,841,872,953,986,1072,1107,

%U 1198,1235,1331,1370,1471,1512,1618,1661,1772,1817,1933,1980,2101,2150,2276

%N a(n) is equal to the number of cells in one octant of the octagon of unit squares with side equal n.

%C The octagon is obtained from a square of side 3n-2 cells by removing a triangle of cells from each of the four corners.

%H Paolo Xausa, <a href="/A362869/b362869.txt">Table of n, a(n) for n = 1..10000</a>

%H Anatoliy A. Abramov, <a href="/A362869/a362869.jpg">Illustration of initial terms</a>

%H <a href="/index/Rec#order_05">Index entries for linear recurrences with constant coefficients</a>, signature (1,2,-2,-1,1).

%F a(n) = k*(k + 1)/2 - floor(n^2/4), where k = ceiling((n + 2*(n - 1))/2).

%F G.f.: x*(1 + x + 4*x^2 + x^3)/((1 - x)^3*(1 + x)^2). - _Stefano Spezia_, May 07 2023

%e For n=3, the octagon is a square of side 3n-2 = 7 with corners chopped to leave each side with 3 "*",

%e * * *

%e * * * * *

%e * * * * * * *

%e @ @ @ @ * * *

%e @ @ @ * * * *

%e @ * * * *

%e * * *

%e The a(3) = 8 cells marked "@" are an eighth of the figure and are the primitive cells in the sense that other cells map to them by rotations or reflections.

%t LinearRecurrence[{1,2,-2,-1,1},{1,2,8,11,22},100] (* _Paolo Xausa_, Oct 16 2023 *)

%o (Java)

%o import java.util.function.Function;

%o import java.util.stream.IntStream;

%o public class Main {

%o private static int A362869(int n) {

%o Function<Integer, Integer> trianglarNumber = p -> p * (p + 1) / 2;

%o Function<Integer, Integer> quarterOfSquareNumber = p -> p * p / 4;

%o int k = (n + 2 * (n - 1) + 1) / 2;

%o return trianglarNumber.apply(k) - quarterOfSquareNumber.apply(n);

%o }

%o public static void main(String[] args) {

%o IntStream.range(1, 100).forEach(n -> System.out.print(A362869(n) + ", "));

%o }

%o }

%Y Cf. A000217, A002620.

%K nonn,easy

%O 1,2

%A _Anatoliy A. Abramov_, May 07 2023