OFFSET
0,3
COMMENTS
If the leftmost digit in n is even, wrap around and replace it with the rightmost digit in n (see example).
LINKS
Michael De Vlieger, Table of n, a(n) for n = 0..10000
EXAMPLE
n = 4 2 7 8 1
^ ^ ^ even digits,
a(n) = 1 4 7 7 1 to their left in n
MATHEMATICA
Array[FromDigits@ Map[If[EvenQ@ #1, #2, #1] & @@ # &, Transpose@ {#, RotateRight[#, 1]}] &@ IntegerDigits[#] &, 67] (* Michael De Vlieger, Jun 19 2022 *)
PROG
(Python)
def a(n):
digits = list(map(int, str(n)))
out = (d if d%2 else digits[i-1] for i, d in enumerate(digits))
return int("".join(map(str, out)))
print([a(n) for n in range(68)]) # Michael S. Branicky, Jun 04 2022
(PARI) prec(d, k) = k--; if (! k, k = #d); k;
a(n) = my(d=digits(n), v=d); for (k=1, #d, if (!(d[k] % 2), v[k] = d[prec(d, k)])); fromdigits(v); \\ Michel Marcus, Jun 04 2022
CROSSREFS
AUTHOR
Gavin Lupo, Jun 03 2022
STATUS
approved