login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A137843 Define S(1) = {1}, S(n+1) = S(n) U S(n) if a(n) is even, S(n+1) = S(n) U (n+1) 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.). 4
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, 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, 7, 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, 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 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,2
LINKS
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)))))))))))
(definec (A291753 n) (if (= 1 n) 1 (+ (* 2 (A291753 (- n 1))) (A000035 (A137843 (- n 1))))))
(define (A000035 n) (modulo n 2))
;; Antti Karttunen, Aug 31 2017
CROSSREFS
Cf. A096055, A137844 (variants of the same theme).
Cf. A291753 (the length of stage n).
Sequence in context: A266685 A272620 A304080 * A130194 A113926 A276376
KEYWORD
easy,nonn
AUTHOR
Leroy Quet, Feb 13 2008
EXTENSIONS
More terms from Antti Karttunen, Aug 31 2017
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 25 03:15 EDT 2024. Contains 371964 sequences. (Running on oeis4.)