OFFSET
0,5
COMMENTS
a(n) gives the number above n when the natural numbers are represented as a square array, or 0 if n is in the top row.
1 3 6 10
2 5 9
4 8
7
LINKS
Peter Kagey, Table of n, a(n) for n = 0..10000
EXAMPLE
As a regular triangle, sequence begins:
0;
0, 1;
0, 2, 3;
0, 4, 5, 6;
0, 7, 8, 9, 10;
...
MATHEMATICA
Riffle[#, 0] &@ Map[# (# - 1)/2 + Range@ # &, Range[0, 11]] /. {} -> {0} // Flatten (* Michael De Vlieger, Apr 07 2016 *)
PROG
(Python)
from math import isqrt
def A271439(n): return n-m+(k<r) if (k:=n<<1)!=(r:=(m:=isqrt(k))*(m+1)) else 0 # Chai Wah Wu, Nov 07 2024
CROSSREFS
KEYWORD
nonn,tabl
AUTHOR
Peter Kagey, Apr 07 2016
STATUS
approved