Look at the rightmost two digits of the number. Are they divisible by 4? If so, the entire number is evenly divisible by 4.

For example:

Is 2,358,224 evenly divisible by 4?

Yes, because 24 is evenly divisible by 4. Doing the check, we see that 589,556 x 4 = 2,358,224.


* This writeup should REALLY be called, "How to determine whether a number is evenly divisible by 4," but I wanted it to fit in with the other "how to determine whether a number is divisible by x" nodes.
Take a number I where I > 100.

For any I it can be re-written as
(j * 25 + k) * 4
Applying the distributive property
(j * 25 * 4) + (k * 4)
And simplifying
j * 100 + (k * 4)
where j is a whole number and 0 < k < 25.

Because (j * 25) * 4 always ends in '00', the last two digits will be result of k * 4. If k is an integer number, the resulting last two digits will be evenly divisible by 4 and return the integer k.

It should be noted that this does not help with numbers less than 100, for which it is necessary to test more conventionally, such as dividing the number by two, and then testing to see if the number is even.

This rule works for any number that is a factor of 100: 2, 4, 5, 10, 25, 50. '4' just happens to be the most interesting of them that doesn't already have another rule. Likewise, this rule would work in other bases, just factor the square of the base. Furthermore, this can be extended to the cube of the base (or further) and would then extend to 'divisible by 8' and testing the last three digits or any other factor for base 10.

Within binary, a number is divisible by four if the last two digits are '00' (this has no relationship to the rule above regarding 100). This can be expressed as a regular language described by the regular expression (0|1)+00 and the corresponding deterministic finite state automaton:

          /--\
         >| n|
          \--/
         /    \
        1      0
       v        v
  /-- /--\       /--\ --\
  1   | 0| <-1-- |*2|   0
  \-> \--/       \--/ <-/
      |  ^    -- 
      0  1     /|
      V  |    0 |
      /--\   /
      | 1|  /
      \--/

Following this DFA, taking 12 as an example (1100), the path followed would be from the start state to state 0 (following the 1), looping on state 0 (following the 1), then to state 1 (following the 0) and then to state 2 (following the 0). Because state 2 is marked as a final state, (marked with a '*'), the number is divisible by 4.

In base 10, the last two digits of multiples of four loop every 5 numbers:

00    04    08
   12    16
--------------
20    24    28
   32    36
--------------
40 ...
This looping causes a very distinct pattern to form:
  • The digits 0, 4, 8 only follow even numbers
  • The digits 2, 6 only follow odd numbers

Log in or registerto write something here or to contact authors.