How many positive integers less than 5,000 have at most two different digits.
There are
9 1 digit numbers
90 2 digit numbers
252 3 digit numbers
257 4 digit numbers
for a total of 608
the 3 digit number breakdown is as follows, n and m are distinct non-zero digits
9 nnn
9*8=72 nnm
9*8=72 nmn
9*8=72 nmm
9 nn0
9 n0n
9 n00
I leave working out the 4 digit breakdown to you.