OFFSET
0,4
COMMENTS
For n > 0, as long as we have a number whose decimal representation is the concatenation of a positive even number, say u, and a possibly empty string of odd digits, say v, we replace this number with the concatenation of u/2 and v; eventually only odd digits remain.
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..10000
Rémy Sigrist, Logarithmic scatterplot of the first 1000000 terms
FORMULA
a(n) <= n with equality iff n = 0 or n belongs to A014261.
a(2*n) = a(n).
a(10*k + v) = 10*a(k) + v for any k >= 0 and v in {1, 3, 5, 7, 9}.
a(n) = 1 iff n is a power of 2.
a(n) = 3 iff n belongs to A007283.
a(n) = 5 iff n belongs to A020714.
a(n) = 7 iff n belongs to A005009.
a(n) = 9 iff n belongs to A005010.
a(n) = a(n+1) iff n belongs to A215145.
EXAMPLE
For n = 10000:
- 10000 gives 10000/2 = 5000,
- 5000 gives 5000/2 = 2500,
- 2500 gives 2500/2 = 1250,
- 1250 gives 125/2 = 625,
- 625 gives 62/2 followed by 5 = 315,
- 315 has only odd digits, so a(10000) = 315.
MATHEMATICA
Array[FixedPoint[If[AllTrue[#, OddQ], FromDigits@ #, FromDigits@ Flatten@ Join[IntegerDigitsFromDigits[First[#]]/2, Last[#]] &@ TakeDrop[#, Position[#, _?EvenQ][[-1, -1]] ] ] &@ IntegerDigits[#] &, #] &, 71] (* Michael De Vlieger, Dec 01 2019 *)
PROG
(PARI) a(n) = if (n==0, 0, n%2==0, a(n/2), 10*a(n\10)+(n%10))
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Rémy Sigrist, Nov 29 2019
STATUS
approved