Well first, in order for you to understand why it doesn't work with 20, let's try this example:
Suppose I had a function that takes 2 numbers. It looks at the digits of the second number, and if a digit is zero then it makes that same digit in the first number zero too, otherwise (not zero) it does nothing. So, for example:
Code:
PRINT MyFreakyFunction(12345, 10101)
would print 10305.
Now suppose I wanted to MOD 12345 by 10000. That's 2345, right? Now, here's how would you use my function to do the same thing:
Code:
PRINT MyFreakyFunction(12345, 10000 - 1)
Which is the same thing as this:
Code:
PRINT MyFreakyFunction(12345, 09999)
So the 1 gets dropped and you're left with 2345 - it works!
Now let's say we want to MOD it by 2. The answer should be 1 (because it's odd). Like this right? 2 minus 1 is 1, so:
Code:
PRINT MyFreakyFunction(12345, 1)
And it gives us 5 :-( Looks like it only works with powers of 10 (10, 100, 1000, etc...)
AND is a lot like my function, except it works in binary instead of decimal. In binary, you carry at 2 instead of 10. So the only digits are 1 and 0. Mine only works for powers of 10, and the AND method only works for powers of 2 (2, 4, 8, 16, etc...), for the same reason.