%I #13 Sep 09 2017 19:30:42
%S 0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,4,4,4,4,4,5,
%T 5,5,5,7,7,7,7,7,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,
%U 1,1,4,4,4,4,4,5,5,5,5,7,7,7,7,7,14,14,14,14,14,14,14,14,14,14,15,15,15,15,18
%N a(n) = difference between n and the n-th Catalan restricted growth string [b_k, b_{k-1}, ..., b_2, b_1] (see A239903) when it is viewed as a simple numeral in Catalan Base: b_k*C(k) + b_{k-1}*C(k-1) + ... + b_2*C(2) +b_1*C(1). Here C(m) = A000108(m).
%H Antti Karttunen, <a href="/A244157/b244157.txt">Table of n, a(n) for n = 0..16796</a>
%F a(n) = n - A244158(A239903(n)) up to 58784, after which the "digits" in Catalan restricted growth strings grow larger than 9 and their decimal representation used in A239903 starts corrupting the results.
%F At n=58785 (= C(11)-1, where C(k) = the k-th Catalan number, A000108(k)), the correct value for this sequence is a(58785) = 58785 - ((1*C(10)) + (2*C(9)) + (3*C(8)) + (4*C(7)) + (5*C(6)) + (6*C(5)) + (7*C(4)) + (8*C(3)) + (9*C(2)) + (10*C(1))) = 25181.
%F Use the Scheme-program given in the Program sections of this entry and A239903 (the function A239903raw) to get correct results for all n.
%o (Scheme)
%o (define (A244157 n) (- n (CatBaseSum (A239903raw n)))) ;; A239903raw given in A239903.
%o (define (CatBaseSum lista) (let loop ((digits (reverse lista)) (i 1) (s 0)) (if (null? digits) s (loop (cdr digits) (+ i 1) (+ s (* (car digits) (A000108 i)))))))
%Y A244155 gives the positions of zeros, A244156 the positions of nonzeros.
%Y Cf. A000108, A239903, A014418, A244158.
%K nonn
%O 0,29
%A _Antti Karttunen_, Jun 22 2014
|