%I
%S 0,0,1,0,0,2,0,1,0,0,1,0,0,2,3,0,1,0,0,2,0,1,0,0,1,0,0,2,0,1,0,0,1,0,
%T 0,2,3,0,1,0,0,2,4,0,1,0,0,2,0,1,0,0,1,0,0,2,3,0,1,0,0,2,0,1,0,0,1,0,
%U 0,2,0,1,0,0,1,0,0,2,3,0,1,0,0,2,0,1,0,0,1,0,0,2,0,1,0,0,1,0,0,2,3,0,1,0,0,2,4,0,1,0,0,2,0,1,0,0,1,0,0,2,3,0,1,0,0,2,0,1,0,0,1,0,5
%N a(0) = 0, after which, if A176137(n) = 1, a(n) = A007814(A244230(n)), otherwise a(n) = a(nA197433(A244230(n)1)).
%C For n >= 1, a(n) tells the zerobased position of the digit (from the right) where the iteration stopped at, when constructing a Semigreedy Catalan representation of n as described in A244159.
%H Antti Karttunen, <a href="/A244315/b244315.txt">Table of n, a(n) for n = 0..4862</a>
%F a(0) = 0, and for n >= 1, if A176137(n) = 1, a(n) = A007814(A244230(n)), otherwise a(n) = a(nA197433(A244230(n)1)).
%o (Scheme, two alternative versions)
%o ;; This version is based on the given recurrence and uses memoizing definecmacro from _Antti Karttunen_'s IntSeqlibrary:
%o (definec (A244315 n) (cond ((zero? n) n) ((not (zero? (A176137 n))) (A007814 (A244230 n))) (else (A244315 ( n (A197433 (1+ (A244230 n))))))))
%o (define (A244315 n) (let outer_loop ((n n)) (let inner_loop ((n n) (i (A244160 n))) (cond ((zero? n) i) ((zero? i) (outer_loop n)) ((<= (A000108 i) n) (inner_loop ( n (A000108 i)) ( i 1))) (else (inner_loop n ( i 1)))))))
%Y One less than A244316.
%Y Cf. A000108, A007814, A176137, A197433, A244230, A244159.
%K nonn
%O 0,6
%A _Antti Karttunen_, Jun 25 2014
