A383788 Smallest number obtainable by either keeping each decimal digit d in n or replacing it with 9-d.
1, 2, 3, 4, 4, 3, 2, 1, 0, 10, 11, 12, 13, 14, 14, 13, 12, 11, 10, 20, 21, 22, 23, 24, 24, 23, 22, 21, 20, 30, 31, 32, 33, 34, 34, 33, 32, 31, 30, 40, 41, 42, 43, 44, 44, 43, 42, 41, 40, 40, 41, 42, 43, 44, 44, 43, 42, 41, 40, 30, 31, 32, 33, 34, 34, 33, 32, 31, 30, 20, 21, 22, 23, 24, 24, 23, 22
Offset: 1
Examples
To find a(346), we replace 6 with 3. So, a(346) = 343.
Programs
-
Mathematica
a[n_] := FromDigits[IntegerDigits[n] /. d_?(# > 4 &) -> 9 - d]; Array[a, 100] (* Amiram Eldar, May 10 2025 *)
-
PARI
a(n) = fromdigits(apply(x->(if (x>4, 9-x, x)), digits(n))); \\ Michel Marcus, May 12 2025
-
Python
def a(n): return int("".join(d if d<"5" else str(9-int(d)) for d in str(n))) print([a(n) for n in range(1, 78)]) # Michael S. Branicky, May 10 2025