Divisibility Rules for different divisors
For Divisor = 1
There is no specific condition. Every number is divisible by 1.
For Divisor = 2
If the last digit of the number is even, then that number is divisible by 2. For example, 0, 2, 4, 6, 8.
For Divisor = 3
- The sum of the digits is divisible by 3, then that number is also divisible by 3.
- Subtract the quantity of the digits 2, 5 & 8 from the quantity of the digits 1, 4, & 7. If this difference is divisible by 3, then that number is also divisible by 3. For Example, 16,499,205,854,376 has four of the digits 1, 4 and 7 and four of the digits 2, 5 and 8; since 4 − 4 = 0 is a multiple of 3, the number 16,499,205,854,376 is divisible by 3.
- Subtracting the last digit of the number twice from the rest of the number. If this difference is divisible by 3, then that number is also divisible by 3. _ For Example, 405: 40 − 5 × 2 = 40 − 10 = 30 = 3 × 10._
For Divisor = 4
- The last two digits form a number and that number is divisible by 4.
- If the tens digit is even, the ones digit must be 0, 4, or 8.
- If the tens digit is odd, the ones digit must be 2 or 6.
- The sum of the ones digit and double the tens digit is divisible by 4.









there's good divisibility rules up to like 20 btw
Divisibility rules for numbers 1−30
a number n is divisible by m if
n%m==0you don't need all that dawgMetacommentary: for the one about three, as kaislash said n%m == 0 is probably a better test in nearly all cases (n < 1e18) since in checking for each digit of n is sum of mult of 3 will firstly still take o(logn) (each digit) time to get the sum but then you also have to recursively figure out if that sum is also a multiple of three which technically works but seems like implement hell. For divisor 4 i guess you could just do (n%100) (to get last 2 digits) then (n%100)%4 == 4 but at that point just do n%4 and atp i think its starting to become clear that using n%x==0 where x is the number testing for division is probably best. Interestingly, there are rules up to like a thousand or so somewhere on the depths of internet if you are really interested in that sort of thing.