## Test if a number is divisible by a power of 2

Posted August 18th, 2007 by Isoscel

To test if a number is divisible by 2 is very easy: we just look at its last digit.

If the last digit is even than the number is even.

How do we test if it's divisible by 4? We look at the last 2 digits.

If the number formed by them is divisible by 4 then the whole number is divisible by 4.

For example 473624 is divisible by 4 because 24 is divisible by 4.

For 8? We look at the last 3 digits. For 16 at the last 4.

So for we just consider the number formed by the last n digits.