login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

The lower (or left) offset of a 196-iterate (A006960) from the largest palindrome less than the iterate.
2

%I #34 Mar 19 2023 03:35:01

%S 5,9,14,99,52,89,100,407,268,10769,10890,99,99,4400,8900,9890,10000,

%T 97625,1089,3584,99,629882,1099890,10989,926,890000,8491505,10890099,

%U 8229644,9999989,69923062,10890000,99099000,43337905,99990089,962943454,109890,454649691

%N The lower (or left) offset of a 196-iterate (A006960) from the largest palindrome less than the iterate.

%C When normalized over (0,1) by their respective palindrome-free interval about a 196-iterate, it has been empirically observed that the frequency distribution of this sequence appears to be quite symmetric about 0.5, as well as fractal when plotting the distribution over decreasing bin sizes.

%C The 196-iterates referred to here come from the reverse-and-add process generating A006960.

%F a(n) = A331560(n) - A331557(n).

%e The first term is 5 since 196-191 = 5

%e The second term is 9 since 887-878 = 9, etc.

%t Map[Block[{k = # - 1}, While[k != IntegerReverse@ k, k--]; # - k] &, NestList[# + IntegerReverse[#] &, 196, 25]] (* brute force, or *)

%t Map[# - Block[{n = #, w, len, ww}, w = IntegerDigits[n]; len = Length@ w; ww = Take[w, Ceiling[len/2] ]; If[# < n, #, FromDigits@ Flatten@{#, If[OddQ@ len, Reverse@ Most@ #, Reverse@ #]} &@ If[Last@ ww == 0, MapAt[# - 1 &, Most@ ww, -1]~Join~{9}, MapAt[# - 1 &, ww, -1]]] &@ FromDigits@ Flatten@ {ww, If[OddQ@ len, Reverse@ Most@ ww, Reverse@ ww]}] &, NestList[# + IntegerReverse[#] &, 196, 37]] (* _Michael De Vlieger_, Jan 22 2020 *)

%o (Python)

%o # Slow Brute-force

%o n = 196

%o while n < 10**15:

%o m = n

%o while m != int(str(m)[::-1]): m+=-1

%o print(n-m, end=', ')

%o n = n + int(str(n)[::-1])

%Y Cf. A006960, A331557, A331560.

%K nonn,base

%O 1,1

%A _James D. Klein_, Jan 20 2020

%E More terms from _Michael De Vlieger_, Jan 22 2020