This should be easy if you break it into no digit repeating, one digit repeating and two digits repeating (you cannot have 3 digits repeating in a 5 digit number).
There are 9P5 = 15,120 permutations without any digit repeating.
There are 9C4 * 5!/2! = 7,560 permutations with one digit repeating. 9C4 for choosing 4 digits letting one repeat and 5!/2! for arranging the 5 digits.
Similarly, there are 9C3 * 5!/2!^2 = 2,520 permutations with two digits repeating.
Overall, there are 25,200 5 digit numbers with no digit repeating more than twice. This is still only just about 1/4th of 90,000 possible 5 digit numbers.
Source:Quora. I myself haven't worked it out. You can refer d link mentioned below for more information.
https://www.quora.com/How-many-5-digit-numbers-can-be-formed-from-numbers-1-through-9-if-no-digit-can-appear-more-than-twice