[seqfan] Subtract largest binary palindrome

Allan Wechsler acwacw at gmail.com
Wed Apr 25 01:00:18 CEST 2018


Let f(n) be the largest binary palindrome that does not exceed a
non-negative integer n. This function is in OEIS as A206913.

I was surprised to find that (n - f(n)), the number you get when you
subtract out the biggest possible palindrome, was not present. This starts
out

0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 4, 5, 0

and this sequence is already not in OEIS, not even after trimming the first
few entries.  Call this function g(n).

It is a natural question to start with a number n and repeatedly subtract
the largest possible palindrome, to see how many it takes to reach 0. This
is the greedy algorithm for partitioning an integer into palindromic parts,
and it is equivalent to iterating g(n). Call the number of steps to reach 0
h(n). This also is not in OEIS, but there is a near contender, A259656.

In that sequence, instead of subtracting the largest palindrome, you
subtract the number with binary representation reversed. The result might
be negative, so you use absolute difference. Again, you count the number of
steps it takes to reach 0. A259626(n) agrees with h(n) through n=37, but
A259626(38) = 4, while h(38) = 2 (because g(38) = 31 and 38-31 is the
palindrome 7).

I have not explored these sequences further, but they seem interesting.



More information about the SeqFan mailing list