A214856 Number of triangular numbers in interval ](n-1)^2, n^2] for n>0, a(0)=1.
1, 1, 1, 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, 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, 2, 1, 2, 1, 1
Offset: 0
Examples
10, 15 are in interval ]9, 16] , a(4) = 2.
Links
- Alois P. Heinz, Table of n, a(n) for n = 0..10000
Programs
-
PARI
a(n) = if (n, sum(i=(n-1)^2+1, n^2, ispolygonal(i, 3)), 1); \\ Michel Marcus, Nov 12 2022
-
Python
from math import isqrt def A214856(n): return (isqrt((m:=n**2<<3)+8)+1>>1)-(isqrt(m-(n-1<<4))+1>>1) if n else 1 # Chai Wah Wu, Dec 09 2024