%I #15 Nov 10 2023 12:28:06
%S 15,26,37,40,48,51,59,62,73,84,95,104,115,125,135,140,145,151,152,153,
%T 154,155,204,215,226,236,240,246,251,256,262,263,264,265,266,304,315,
%U 326,337,340,347,351,357,362,367,373,374,375,376,377,400,401,402,403,404,410
%N Numbers whose difference between the largest and smallest digits is equal to 4.
%C The number of n-digit terms is 29*5^(n-1) - 47*4^(n-1) + 2*3^(n+1).
%t Select[Range[410],Max[d=IntegerDigits[#]]-Min[d]==4 &]
%o (Python)
%o def ok(n): return max(d:=list(map(int, str(n))))-min(d) == 4
%o print([k for k in range(411) if ok(k)]) # _Michael S. Branicky_, Oct 30 2023
%o (PARI) isok(n) = my(d=digits(n)); vecmax(d) - vecmin(d) == 4; \\ _Michel Marcus_, Nov 05 2023
%Y Cf. A037904.
%Y Cf. A010785 (difference = 0), A366958 (difference = 1), A366959 (difference = 2), A366960 (difference = 3), A366962 (difference = 5), A366963 (difference = 6), A366964 (difference = 7), A366965 (difference = 8), A366966 (difference = 9).
%K nonn,base,easy
%O 1,1
%A _Stefano Spezia_, Oct 30 2023