Here is the process:
For example:
You have to find the number of integers between 1-999 that doesnt contain 3
formula : (9^3) - 1 = 728
Long method.
one digit number (1,2,4,5,6,7,8,9) = 8 ways
two digit number (0,1,2,4,5,6,7,8,9), first digit cannot be 0 = 8*9 ways
three digit number (0,1,2,4,5,6,7,8,9), first digit cannot be 0 = 8*9*9 ways
8 + 72 + 648 = 728
You have to find the number of integers between 1-1000 that doesnt contain 3
formula : 9^3 = 729
Long Method.
one digit number (1,2,4,5,6,7,8,9) = 8 ways
two digit number (0,1,2,4,5,6,7,8,9), first digit cannot be 0 = 8*9 ways
three digit number (0,1,2,4,5,6,7,8,9), first digit cannot be 0 = 8*9*9 ways
four digit number (0,1), first digit cannot be 0 and remaining digit cannot be greater than 0 = 1*1*1*1 = 1 ways
8 + 8*9 + 8*9*9 + 1 = 729
Try to solve the posted question with the same method.
"4meonly" i think you have got the wrong answer, the answer should 6561.
And the algorithm used by "Senator" is a computer program written probably in C++ or php, therefore i dont think he would be able to explain you the program unless you have any prior knowledge of computer programming.
Let me know if you still have any doubts.