The Missing Digit

The number 229 has 9 digits, all different. Which digit is missing?

Bonus: Is the number 9991 prime?


Let the missing digit be m. Every number and the sum of its digits give the same remainder when divided by 9. The number 229 = 32*644 gives remainder 5 when divided by 9, and therefore 9 divides (0 + 1 + 2 + ... + 9) - 5 - m = 40 - m. Thus, the missing digit is 4.

Bonus: 9991 = 10000 - 9 = 1002 - 32 = (100 - 3)(100 + 3) = 97*103. Therefore the number 9991 is not prime.