OFFSET
1,2
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
LINKS
Dominic McCarty, Table of n, a(n) for n = 1..10000
EXAMPLE
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.
PROG
(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
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Gary W. Adamson, Jan 29 2008
EXTENSIONS
Edited by Franklin T. Adams-Watters, Mar 29 2014
Name edited by Dominic McCarty, Mar 04 2025
STATUS
approved
