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.

Original entry on oeis.org

1, 3, 6, 7, 13, 15, 25, 26, 28, 31, 49, 53, 59, 63, 97, 102, 106, 109, 115, 116, 120, 127, 193, 201, 213, 221, 227, 235, 247, 255, 385, 398, 406, 409, 421, 426, 434, 445, 451, 460, 468, 475, 487, 488, 496, 511, 769, 785, 809, 825, 837, 853, 877, 893, 899, 915
Offset: 1

Views

Author

Gary W. Adamson, Jan 29 2008

Keywords

Comments

Decimal-binary representations of palindromic continued fractions.
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.
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

Examples

			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.
The fraction corresponding to the encoded continued fraction [0;2,1,1,2] is 5/13.
		

Crossrefs

Cf. A014601.

Programs

  • Python
    from itertools import groupby
    def ok(n):
        if n == 0: return False
        d = [len(list(g[1])) for g in groupby(bin(n)[2:])]
        d[-1] += 1
        return all(d[i]==d[-i-1] for i in range(len(d)//2))
    print((str([n for n in range(100) if ok(n)]))) # Dominic McCarty, Mar 04 2025

Extensions

Edited by Franklin T. Adams-Watters, Mar 29 2014
Name edited by Dominic McCarty, Mar 04 2025