Q.
How many integers with four different digits are there between 1000 and 9999 such that the absolute
value of the difference between the first digit and the last digit is 2?
In the set {0,1,…..,9} there are sixteen pairs of numbers {(0,2),(2,0),(1,3),…..}whose difference is \pm 2 . All but (0,2) can be used as the first and last digit, respectively, of the required number. For each of the 15 ordered pairs, there are 8⋅7=56 ways to fill the remaining middle two digits. Thus there are 15⋅56=840 numbers of the required form.