A378301 a(n) is the number of triangular numbers (A000217) in the interval [n^2, (n + 1)^2].
2, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1
Offset: 0
Keywords
Examples
n = 0: in the interval [0, 1] are 2 triangular numbers {0, 1}, thus a(0) = 2. n = 1: in the interval [1, 4] are 2 triangular numbers {1, 3}, thus a(1) = 2.
Programs
-
Mathematica
s[n_] := Floor[(Sqrt[8*n+1]-1)/2]; a[n_] := s[(n + 1)^2] - s[n^2 - 1]; a[0] = 2; Array[a, 100, 0] (* Amiram Eldar, Dec 09 2024 *)
-
PARI
a(n) = sum(k=n^2, (n+1)^2, ispolygonal(k,3)); \\ Michel Marcus, Dec 09 2024
-
Python
from math import isqrt def A378301(n): return -(isqrt(m:=n**2<<3)+1>>1)+(isqrt(m+(n+1<<4))+1>>1) # Chai Wah Wu, Dec 09 2024
Formula
a(n) = 2 for n from A001110.
Extensions
a(53) corrected by Michel Marcus, Dec 09 2024
Comments