Is `\large{`

divisible by
`NUMBER`}

?
`FACTOR`

`DIVISIBLE ? "Yes" : "No"`

- Yes
- No

Any even number is divisible by `2`

.

is even, so yes, it is
divisible by `NUMBER``2`

.

is odd, so it is
not divisible by `NUMBER``2`

.

A number is divisible by

if the sum of its digits is divisible by
`FACTOR`

.
[Why?]
`FACTOR`

First, we can break the number up by place value:

```
\qquad\begin{eqnarray}
\blue{
````NUMBER`}=
`integerToDigits(NUMBER).map(function(v, p) {
var placeValue = pow(10,
integerToDigits(NUMBER).length - p - 1);
return "&&\\blue{" + v + "}\\cdot" +
placeValue;
}).join("+ \\\\")`
\end{eqnarray}

Next, we can rewrite each of the place values as
`1`

plus a bunch of `9`

s:

```
\qquad\begin{eqnarray}
\blue{
````NUMBER`}=
`integerToDigits(NUMBER).map(function(v, p) {
var placeValue = pow(10,
integerToDigits(NUMBER).length - p - 1);
if (placeValue === 1) {
return "&&\\blue{" + v + "}";
}
return "&&\\blue{" + v + "}(" +
(placeValue - 1) + "+1)";
}).join("+ \\\\")`
\end{eqnarray}

Now if we distribute and rearrange, we get this:

```
\qquad\begin{eqnarray}
\blue{
````NUMBER`}=
`integerToDigits(NUMBER).map(function(v, p) {
var placeValue = pow(10,
integerToDigits(NUMBER).length - p - 1);
if (placeValue === 1) {
return "";
}
return "&&\\gray{" + v + "\\cdot" +
(placeValue - 1) + "}";
}).join("+ \\\\")`&&
\blue{`integerToDigits(NUMBER)
.join("}+\\blue{")`}
\end{eqnarray}

Any number consisting only of `9`

s is
a multiple of

, so
the first `FACTOR``cardinal(integerToDigits(NUMBER)
.length - 1)` terms must all be multples of

.
`FACTOR`

That means that to figure out whether the original
number is divisible by

, all we need to do is add up the digits
and see if the sum is divisible by
`FACTOR`

. In other words,
`FACTOR``\blue{`

is divisible
by `NUMBER`}

if `FACTOR````
\blue{
```

is divisible by
`integerToDigits(NUMBER).join("}+\\blue{")
`}

!
`FACTOR`

Add the digits of

:`STEP.num`

```
```

`STEP.digits.join("+")` =
`STEP.sum`

If

is
divisible by `STEP.sum`

, then
`FACTOR`

must also be
divisible by `STEP.num`

.
`FACTOR`

is divisible
by `_.last(STEPS).sum`

, therefore
`FACTOR``\blue{`

must also be divisible by `NUMBER`}

.
`FACTOR`

is not divisible
by `_.last(STEPS).sum`

, therefore
`FACTOR``\blue{`

must not be divisible by `NUMBER`}

.
`FACTOR`

A number is divisible by `4`

if the last
two digits are divisible by `4`

.
[Why?]

We can rewrite the number as a multiple of
`100`

plus the last two digits:

```
\qquad
\gray{
````NUMBER.toString().slice(0, -2)`}
\blue{`("00" + (NUMBER % 100)).slice(-2)`} =
\gray{`NUMBER.toString().slice(0, -2)`}
\gray{00} +
\blue{`("00" + (NUMBER % 100)).slice(-2)`}

Because

is a multiple of `NUMBER.toString().slice(0, -2)
`00`100`

,
it is also a multiple of `4`

.

So as long as the value of the last two digits,
`\blue{`

,
is divisible by `NUMBER % 100`}`4`

, the original
number must also be divisible by `4`

!

Is the value of the last two digits,

,
divisible by `NUMBER % 100``4`

?

Yes,
`\blue{`

, so
`NUMBER % 100` \div 4 =
`NUMBER % 100 / 4`}

must also be divisible by
`NUMBER``4`

.

No,

is not
divisible by `NUMBER % 100``4`

, so

is also not divisible by
`NUMBER``4`

.

A number is divisible by `5`

if the last
digit is a `0`

or a `5`

.

The last digit of

is
`NUMBER`

, so yes
`NUMBER % 10`

is divisible by
`NUMBER``5`

.

The last digit of

is
`NUMBER`

, so no
`NUMBER % 10`

is not divisible by
`NUMBER``5`

.

A number is divisible by `10`

if the last
digit is a `0`

.

The last digit of

is
`NUMBER`

, so yes
`NUMBER % 10`

is divisible by
`NUMBER``10`

.

The last digit of

is
`NUMBER`

, so no
`NUMBER % 10`

is not divisible by
`NUMBER``10`

.