OFFSET
0,3
COMMENTS
n is read one digit at a time, leftover single digits describe themselves and trailing zeros are ignored.
In many, but not all cases, a(n) acts as an inverse to the "Look and Say" sequence A005150. For example, 4113 -> 142113 under the "Look and Say" and 142113 -> 4113 under a(n).
EXAMPLE
142113 can be read as one "4", two "1"s, one "3" and so describes 4113. Hence a(142113) = 4113. 123 can be read as one "2", "3" and so describes 23. (The leftover digit 3 describes itself.) Hence a(123) = 23. Note that a(1213) = 23 also. 40 can be read as four "0"s, so a(40) = 0. (Trailing zeros are ignored.) 4. a(5) = 5. A single digit describes itself.
MATHEMATICA
a[n_] := Table[#[[2]], {#[[1]]}]& /@ Partition[If[EvenQ[Length[id = IntegerDigits[n]]], id, Join[Most[id], {1}, {id[[-1]]}]], 2] // Flatten // FromDigits; Table[a[n], {n, 0, 123}] (* Jean-François Alcover, Mar 02 2017 *)
PROG
(Python)
def A079475(n):
s = str(n)
l = len(s)
if l % 2:
s = s[:-1]+'1'+s[-1]
return int(''.join(s[i+1]*int(s[i]) for i in range(0, l, 2))) # Chai Wah Wu, Sep 01 2021
CROSSREFS
KEYWORD
base,nonn,nice
AUTHOR
Joseph L. Pe, Jan 15 2003
STATUS
approved