This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A003157 M2713 #34 Apr 21 2025 08:37:00 %S A003157 3,8,11,14,19,24,29,32,35,40,43,46,51,54,57,62,67,72,75,78,83,88,93, %T A003157 96,99,104,109,114,117,120,125,128,131,136,139,142,147,152,157,160 %N A003157 A self-generating sequence (see Comments in A003156 for the definition). %C A003157 Indices of c in the sequence closed under a -> abc, b -> a, c -> a, starting with a(1) = a; see A092606 where a = 0, b = 2, c = 1. - _Philippe Deléham_, Apr 12 2004 %C A003157 These are the positions of 1 in A286044; complement of A286045; conjecture: a(n)/n -> 4. - _Clark Kimberling_, May 07 2017 %D A003157 N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence). %H A003157 Clark Kimberling, <a href="/A003157/b003157.txt">Table of n, a(n) for n = 1..10000</a> %H A003157 L. Carlitz, R. Scoville, and V. E. Hoggatt, Jr., <a href="https://web.archive.org/web/2024*/https://www.fq.math.ca/Scanned/10-5/carlitz3-a.pdf">Representations for a special sequence</a>, Fibonacci Quarterly 10.5 (1972), 499-518, 550. %F A003157 Numbers n such that A003159(n) is even. a(n) = A003158(n) + 1 = A036554(n) + n. - _Philippe Deléham_, Feb 22 2004 %e A003157 As a word, A286044 = 001000010010010000100..., in which 1 is in positions a(n) for n>=1. - _Clark Kimberling_, May 07 2017 %t A003157 s = Nest[Flatten[# /. {0 -> {0, 1}, 1 -> {1, 0}}] &, {0}, 9] (* Thue-Morse, A010060 *) %t A003157 w = StringJoin[Map[ToString, s]] %t A003157 w1 = StringReplace[w, {"011" -> "0"}] %t A003157 st = ToCharacterCode[w1] - 48 (* A286044 *) %t A003157 Flatten[Position[st, 0]] (* A286045 *) %t A003157 Flatten[Position[st, 1]] (* A003157 *) %t A003157 (* _Clark Kimberling_, May 07 2017 *) %o A003157 (Python) %o A003157 def A003157(n): %o A003157 def bisection(f,kmin=0,kmax=1): %o A003157 while f(kmax) > kmax: kmax <<= 1 %o A003157 kmin = kmax >> 1 %o A003157 while kmax-kmin > 1: %o A003157 kmid = kmax+kmin>>1 %o A003157 if f(kmid) <= kmid: %o A003157 kmax = kmid %o A003157 else: %o A003157 kmin = kmid %o A003157 return kmax %o A003157 def f(x): %o A003157 c, s = n+x, bin(x)[2:] %o A003157 l = len(s) %o A003157 for i in range(l&1,l,2): %o A003157 c -= int(s[i])+int('0'+s[:i],2) %o A003157 return c %o A003157 return bisection(f,n,n)+n # _Chai Wah Wu_, Jan 29 2025 %Y A003157 Cf. A003156, A003158, A010060, A286044, A286045. %K A003157 nonn %O A003157 1,1 %A A003157 _N. J. A. Sloane_