%I #31 Feb 28 2020 02:05:05
%S 0,2,2,6,4,20,6,24,8,28,20,22,22,26,24,60,26,64,28,68,20,42,22,46,24,
%T 200,26,204,28,208,60,62,62,66,64,240,66,244,68,248,40,82,42,86,44,
%U 280,46,284,48,288,200,202,202,206,204,220,206,224,208,228,60,222
%N Starting from n: as long as the decimal representation starts with an odd number, multiply the largest such prefix by 2; a(n) corresponds to the final value.
%C As long as we have a number whose decimal representation is the concatenation of odd number, say u, and a possibly empty string of even digits allowing leading zeros, say v, we replace this number with the concatenation of u*2 and v; eventually only even digits remain.
%H Rémy Sigrist, <a href="/A329249/b329249.txt">Table of n, a(n) for n = 0..10000</a>
%F a(n) >= n with equality iff n belongs to A014263.
%F a(2*n+1) = a(4*n+2).
%F a(10*k + v) = 10*a(k) + v for any k >= 0 and v in {0, 2, 4, 6, 8}.
%F a(5^k) = 2*10^k for any k >= 0 (the ratio a(n)/n is unbounded).
%e For n = 127:
%e - 127 gives 127*2 = 254,
%e - 254 gives 25*2 followed by 4 = 504,
%e - 504 gives 5*2 followed by 04 = 1004,
%e - 1004 gives 1*2 followed by 004 = 2004,
%e - 2004 has only even digits, so a(127) = 2004.
%t {0}~Join~Array[FixedPoint[If[AllTrue[#, EvenQ], FromDigits@ #, FromDigits@ Flatten@ Join[2 IntegerDigits@ FromDigits[First[#]], Last[#]] &@ TakeDrop[#, Position[#, _?OddQ][[-1, -1]] ] ] &@ IntegerDigits[#] &, #] &, 61] (* _Michael De Vlieger_, Dec 01 2019 *)
%o (PARI) a(n) = if (n==0, 0, n%2, a(2*n), 10*a(n\10)+(n%10))
%Y See A327539 for similar sequences.
%Y Cf. A014263.
%K nonn,base
%O 0,2
%A _Rémy Sigrist_, Nov 30 2019
|