login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A338830
a(n) is the greatest number not yet in the sequence with the same number of digits and the same largest digit as n.
2
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 10, 22, 33, 44, 55, 66, 77, 88, 99, 21, 20, 12, 32, 43, 54, 65, 76, 87, 98, 31, 30, 23, 13, 42, 53, 64, 75, 86, 97, 41, 40, 34, 24, 14, 52, 63, 74, 85, 96, 51, 50, 45, 35, 25, 15, 62, 73, 84, 95, 61, 60, 56, 46, 36, 26, 16, 72
OFFSET
0,3
COMMENTS
This sequence is a self-inverse permutation of the nonnegative integers.
FORMULA
A055642(a(n)) = A055642(n).
A054055(a(n)) = A054055(n).
EXAMPLE
For n = 20:
- the numbers with 2 digits and largest digit 2 are: 12, 20, 21 and 22,
- so a(12) = 22,
a(20) = 21,
a(21) = 20,
a(22) = 12.
MATHEMATICA
Block[{a = {}, f, k}, f[x_] := Max@ IntegerDigits@ x; Do[k = f[i]; AppendTo[a, SelectFirst[Range[10^# - 1, 10^(# - 1), -1] &@ Floor[1 + Log10[i]], And[f[#] == k, FreeQ[a, #]] &]], {i, 67}]; a] (* Michael De Vlieger, Nov 13 2020 *)
PROG
(PARI) See Links section.
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Nov 11 2020
STATUS
approved