OFFSET
1,2
LINKS
Antti Karttunen, Table of n, a(n) for n = 1..27995, up to the stage S(15)
EXAMPLE
S(1) = {1}.
S(2) = {1,2,1}, because a(1) = 1, which is odd.
S(3) = {1,2,1,1,2,1}, because a(2) = 2, which is even.
S(4) = {1,2,1,1,2,1,4,1,2,1,1,2,1}, as a(3) is odd.
S(5) = {1,2,1,1,2,1,4,1,2,1,1,2,1,5,1,2,1,1,2,1,4,1,2,1,1,2,1}, as a(4) is odd.
Etc.
PROG
(Scheme, with memoization-macro definec)
(definec (A137843 n) (if (= 1 n) n (let ((k (let loop ((j 1)) (if (>= (A291753 j) n) j (loop (+ 1 j)))))) (cond ((= (+ 1 (A291753 (- k 1))) n) (if (odd? (A137843 (- k 1))) k 1)) (else (A137843 (- n (+ (A291753 (- k 1)) (A000035 (A137843 (- k 1)))))))))))
(define (A000035 n) (modulo n 2))
;; Antti Karttunen, Aug 31 2017
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Leroy Quet, Feb 13 2008
EXTENSIONS
More terms from Antti Karttunen, Aug 31 2017
STATUS
approved