%I #12 Nov 10 2023 12:27:57
%S 18,29,70,81,92,107,118,128,138,148,158,168,170,178,181,182,183,184,
%T 185,186,187,188,207,218,229,239,249,259,269,270,279,281,289,292,293,
%U 294,295,296,297,298,299,307,318,329,370,381,392,407,418,429,470,481,492
%N Numbers whose difference between the largest and smallest digits is equal to 7.
%C The number of n-digit terms is 23*8^(n-1) - 41*7^(n-1) + 2^n*3^(n+1).
%t Select[Range[500],Max[d=IntegerDigits[#]]-Min[d]==7 &]
%o (Python)
%o def ok(n): return max(d:=list(map(int, str(n))))-min(d) == 7
%o print([k for k in range(500) if ok(k)]) # _Michael S. Branicky_, Oct 30 2023
%o (PARI) isok(n) = my(d=digits(n)); vecmax(d) - vecmin(d) == 7; \\ _Michel Marcus_, Nov 05 2023
%Y Cf. A037904.
%Y Cf. A010785 (difference = 0), A366958 (difference = 1), A366959 (difference = 2), A366960 (difference = 3), A366961 (difference = 4), A366962 (difference = 5), A366963 (difference = 6), A366965 (difference = 8), A366966 (difference = 9).
%K nonn,base,easy
%O 1,1
%A _Stefano Spezia_, Oct 30 2023
|