A329249 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.
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, 200, 26, 204, 28, 208, 60, 62, 62, 66, 64, 240, 66, 244, 68, 248, 40, 82, 42, 86, 44, 280, 46, 284, 48, 288, 200, 202, 202, 206, 204, 220, 206, 224, 208, 228, 60, 222
Offset: 0
Examples
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.
Links
- Rémy Sigrist, Table of n, a(n) for n = 0..10000
Programs
-
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 *)
-
PARI
a(n) = if (n==0, 0, n%2, a(2*n), 10*a(n\10)+(n%10))
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).
Comments