A371032 a(n) is the integer whose decimal digits are 0's or 1's in alternating runs of lengths n, n-1, n-2, ..., 3, 2, 1.
1, 110, 111001, 1111000110, 111110000111001, 111111000001111000110, 1111111000000111110000111001, 111111110000000111111000001111000110, 111111111000000001111111000000111110000111001, 1111111111000000000111111110000000111111000001111000110
Offset: 1
Examples
a(1) = 1 has runlength 1; a(2) = 110 has runlengths 2,1; a(3) = 111001 has runlengths 3,2,1.
Programs
-
Maple
f:= proc(n) option remember; (10^(n*(n+1)/2)-1)/9 - procname(n-1) end proc: f(1):= 1: map(f, [$1..30]); # Robert Israel, Jul 09 2024
-
Mathematica
Flatten[Table[Flatten[Map[ConstantArray[Mod[#, 2], n + 1 - #] &, Range[n]]], {n, 10}]] (* Peter J. C. Moses, Mar 08 2024 *)
-
Python
def A371032(n): c = 0 for i in range(n): c = (m:=10**(n-i))*c if i&1^1: c += (m-1)//9 return c # Chai Wah Wu, Mar 18 2024
Formula
a(n) = (10^(n*(n+1)/2) - 1)/9 - a(n-1). - Robert Israel, Jul 09 2024
Extensions
New name from Michel Marcus, Jul 09 2024