OFFSET
0,2
COMMENTS
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.
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..10000
FORMULA
a(n) >= n with equality iff n belongs to A014263.
a(2*n+1) = a(4*n+2).
a(10*k + v) = 10*a(k) + v for any k >= 0 and v in {0, 2, 4, 6, 8}.
a(5^k) = 2*10^k for any k >= 0 (the ratio a(n)/n is unbounded).
EXAMPLE
For n = 127:
- 127 gives 127*2 = 254,
- 254 gives 25*2 followed by 4 = 504,
- 504 gives 5*2 followed by 04 = 1004,
- 1004 gives 1*2 followed by 004 = 2004,
- 2004 has only even digits, so a(127) = 2004.
MATHEMATICA
{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 *)
PROG
(PARI) a(n) = if (n==0, 0, n%2, a(2*n), 10*a(n\10)+(n%10))
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Nov 30 2019
STATUS
approved