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”).
%I #15 Nov 14 2020 01:50:21
%S 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,
%T 65,76,87,98,31,30,23,13,42,53,64,75,86,97,41,40,34,24,14,52,63,74,85,
%U 96,51,50,45,35,25,15,62,73,84,95,61,60,56,46,36,26,16,72
%N a(n) is the greatest number not yet in the sequence with the same number of digits and the same largest digit as n.
%C This sequence is a self-inverse permutation of the nonnegative integers.
%H Rémy Sigrist, <a href="/A338830/b338830.txt">Table of n, a(n) for n = 0..9999</a>
%H Rémy Sigrist, <a href="/A338830/a338830.png">Colored scatterplot of the first 10000 terms</a> (where the color is function of the largest digit of n)
%H Rémy Sigrist, <a href="/A338830/a338830.gp.txt">PARI program for A338830</a>
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F A055642(a(n)) = A055642(n).
%F A054055(a(n)) = A054055(n).
%e For n = 20:
%e - the numbers with 2 digits and largest digit 2 are: 12, 20, 21 and 22,
%e - so a(12) = 22,
%e a(20) = 21,
%e a(21) = 20,
%e a(22) = 12.
%t 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 *)
%o (PARI) See Links section.
%Y Cf. A054055, A055642, A338831.
%K nonn,base
%O 0,3
%A _Rémy Sigrist_, Nov 11 2020