This site is supported by donations to The OEIS Foundation.

# Divisibility tests

From OeisWiki

This article page is a

**stub**, please help by expanding it.

A **divisibility test** for a given integer determines whether an integer is divisible by without having to compute by examining the base digits of .

- Given an even base , is divisible by 2 if the least significant digit of is 0, 2, 4, ... or .
- Given , is divisible by 3 if the digital root of is 3, 6, 9, ... .
- If is a multiple of 4, then it is enough to check if the least significant digit of is 0, 4, 8, ... or . But if is even but not a multiple of 4 (singly even), then one must look at the two least significant digits to see if they are 00, 04, 08, 12, 16, ... or (this is because then is a multiple of 4).
- The divisibility test for 5 in base 10 is greatly simplified by the fact that the base, 10, is twice 5. Therefore, all we need to determine if an integer is divisible by 5 is to is look at the least significant digit of the base 10 representation to see if it is 0 or 5.
- In the case of 6 we can use a "composite" divisibility test: if passes the tests for 2 and for 3, then it is divisible by 6.
- The divisibility tests for 7 in base 10 are all rather convoluted. One test involves doubling the least significant digit, subtracting that from the concatenation of the other digits, and repeating the procedure until arriving at 7, 0 or –7 (in which case is divisible by 7), or arriving at –6, ... –1, 1, ... 6, in which case it is not divisible by 7. For example: 1729 -> 172 – 18 = 154 -> 15 – 8 = 7, so 1729 is divisible by 7; 225 -> 22 – 10 = 12 -> 1 – 4 = –3, so 225 is not divisible by 7. It seems it would be much easier to just go ahead and compute .
- If is a multiple of 8, then it is enough to check if the least significant digit of is 0, 8, G, ... or . But if is even but not a multiple of 8, or for that matter, of 4, then one must look at the three least significant digits to see if they are 000, 004, 008, 012, 016, ... or (this is because then is a multiple of 8).
- Given , is divisible by 9 if the digital root of is 9, ... .
- is divisible by if the least significant digit of is 0.
- If , then is divisible by if the sum of the even-indexed digits minus the sum of the odd-indexed digits if a multiple of . For example, 1727 is a multiple of 11 since (1 + 2) – (7 + 7) = –11. With 1729 we see that (1 + 2) – (7 + 9) = –13.
- For 12 we once again give a composite divisibility test: if is divisible by 3 and 4.