login
A244315
a(0) = 0, after which, if A176137(n) = 1, a(n) = A007814(A244230(n)), otherwise a(n) = a(n-A197433(A244230(n)-1)).
3
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, 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, 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
OFFSET
0,6
COMMENTS
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.
LINKS
FORMULA
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)).
PROG
(Scheme, two alternative versions)
;; This version is based on the given recurrence and uses memoizing definec-macro from Antti Karttunen's IntSeq-library:
(definec (A244315 n) (cond ((zero? n) n) ((not (zero? (A176137 n))) (A007814 (A244230 n))) (else (A244315 (- n (A197433 (-1+ (A244230 n))))))))
(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)))))))
CROSSREFS
One less than A244316.
Sequence in context: A283497 A265507 A035145 * A214303 A281274 A191250
KEYWORD
nonn
AUTHOR
Antti Karttunen, Jun 25 2014
STATUS
approved