cp's OEIS Frontend

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.

A137595 Integers k such that the run lengths of identical digits in their binary expansion are palindromic after the rightmost bit is duplicated.

This page as a plain text file.
%I A137595 #29 Mar 15 2025 12:33:52
%S A137595 1,3,6,7,13,15,25,26,28,31,49,53,59,63,97,102,106,109,115,116,120,127,
%T A137595 193,201,213,221,227,235,247,255,385,398,406,409,421,426,434,445,451,
%U A137595 460,468,475,487,488,496,511,769,785,809,825,837,853,877,893,899,915
%N A137595 Integers k such that the run lengths of identical digits in their binary expansion are palindromic after the rightmost bit is duplicated.
%C A137595 Decimal-binary representations of palindromic continued fractions.
%C A137595 Using the conversion rules, the first 14 fractions in the Stern-Brocot infinite Farey tree, (rational fractions k, 0 < k < 1) with palindromic continued fraction representations are: 1/2, 1/3, 2/5, 1/4, 3/8, 1/5, 5/12, 5/13, 3/10, 1/6, 7/16, 8/21, 4/15, 1/7.
%C A137595 In other words, this sequence encodes the positive fractions less than 1 with palindromic continued fractions by the order that they appear in the Stern-Brocot infinite Farey tree. The terms of the continued fraction [0; c1, c2, ..., cN] are encoded in the run lengths of the binary digits of k. However, the last term in a continued fraction is always greater than 1, so instead of encoding cN, we encode cN-1. - _Dominic McCarty_, Mar 04 2025
%H A137595 Dominic McCarty, <a href="/A137595/b137595.txt">Table of n, a(n) for n = 1..10000</a>
%e A137595 26 in binary is 11010. Appending a duplicate of the rightmost digit, 0, to the right gives 110100. The run lengths of consecutive identical binary digits is 2,1,1,2, which is a palindrome, so 26 is in the sequence.
%e A137595 The fraction corresponding to the encoded continued fraction [0;2,1,1,2] is 5/13.
%o A137595 (Python)
%o A137595 from itertools import groupby
%o A137595 def ok(n):
%o A137595     if n == 0: return False
%o A137595     d = [len(list(g[1])) for g in groupby(bin(n)[2:])]
%o A137595     d[-1] += 1
%o A137595     return all(d[i]==d[-i-1] for i in range(len(d)//2))
%o A137595 print((str([n for n in range(100) if ok(n)]))) # _Dominic McCarty_, Mar 04 2025
%Y A137595 Cf. A014601.
%K A137595 nonn,base
%O A137595 1,2
%A A137595 _Gary W. Adamson_, Jan 29 2008
%E A137595 Edited by _Franklin T. Adams-Watters_, Mar 29 2014
%E A137595 Name edited by _Dominic McCarty_, Mar 04 2025