Say the code only needed to be one number long. Going from 0-9, there are ten digits. Therefore, there are ten unique codes.
Now say the code has to be two numbers long. There are ten possibilities for the first digit, 0-9. But the second digit only has nine possibilities, since each number has to be different. (The first number might be 0, so the second can only go from 1-9) For each of the first ten possibilities, there are nine possibilities for the second. We multiply those two numbers together, 10 * 9, and we get 90.
Now we just extend the logic. The third number only has eight possibilities, while the fourth number only has seven. 10 * 9 * 8 * 7 = 5040 possible codes. I hope this helped! has a great day! :)