login
A137844
Define S(1) = {1}, S(n+1) = S(n) U S(n) if a(n) is even, S(n+1) = S(n) U n U S(n) if a(n) is odd. Sequence {a(n), n >= 1} is limit as n approaches infinity of S(n). (U represents concatenation.).
3
1, 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1, 1, 5, 1, 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1, 1, 6, 1, 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1, 1, 5, 1, 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1, 1
OFFSET
1,4
EXAMPLE
S(1) = {1}.
S(2) = {1,1,1}, because a(1) = 1, which is odd.
S(3) = {1,1,1,2,1,1,1}, because a(2) = 1, which is odd.
S(4) = {1,1,1,2,1,1,1,3,1,1,1,2,1,1,1}.
S(5) = {1,1,1,2,1,1,1,3,1,1,1,2,1,1,1,1,1,1,2,1,1,1,3,1,1,1,2,1,1,1}, because a(4) = 2, which is even.
Etc.
MATHEMATICA
Fold[Flatten@ Join[#1, If[OddQ[#1[[#2]]], {#2}, {}], #1] &, {1}, Range@ 6] (* Michael De Vlieger, Oct 18 2017 *)
PROG
(Scheme, with memoization-macro definec)
(definec (A137844 n) (if (= 1 n) n (let ((k (let loop ((j 1)) (if (>= (A291754 j) n) j (loop (+ 1 j)))))) (cond ((= (+ 1 (A291754 (- k 1))) n) (if (odd? (A137844 (- k 1))) (- k 1) 1)) (else (A137844 (- n (+ (A291754 (- k 1)) (A000035 (A137844 (- k 1)))))))))))
(definec (A291754 n) (if (= 1 n) 1 (+ (* 2 (A291754 (- n 1))) (A000035 (A137844 (- n 1))))))
(define (A000035 n) (modulo n 2))
;; Antti Karttunen, Aug 31 2017
CROSSREFS
Cf. A137843, A291754 (the length of stage n).
Sequence in context: A111946 A175788 A237513 * A263845 A079229 A344972
KEYWORD
easy,nonn
AUTHOR
Leroy Quet, Feb 13 2008
EXTENSIONS
Data section filled up to the length of stage S(7) by Antti Karttunen, Aug 31 2017
STATUS
approved