%N a(0) = 0, after which, if A176137(n) = 1, a(n) = A007814(A244230(n)), otherwise a(n) = a(n-A197433(A244230(n)-1)).
%C For n >= 1, a(n) tells the zero-based 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(n-A197433(A244230(n)-1)).
%o (Scheme, two alternative versions)
%o ;; This version is based on the given recurrence and uses memoizing definec-macro from _Antti Karttunen_'s IntSeq-library:
%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.
%A _Antti Karttunen_, Jun 25 2014