Skip to content

Instantly share code, notes, and snippets.

@superdaigo
Last active January 2, 2023 01:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save superdaigo/9ad3d1b498afea41c09347e7a99c2be5 to your computer and use it in GitHub Desktop.
Save superdaigo/9ad3d1b498afea41c09347e7a99c2be5 to your computer and use it in GitHub Desktop.

Multiples of 3

If the natural number X is a multiple of 3, the summary of each digit number of X is a multiple of 3 too.

Example:

3 = 3 * 1; For single digit, it's ovbious that the result is multiple of 3.
6 = 3 * 2;
...
12 = 3 * 4; (1 + 2) = 3 = 3 * 1
15 = 3 * 5; (1 + 5) = 6 = 3 * 2
18 = 3 * 6; (1 + 8) = 9 = 3 * 3
21 = 3 * 7; (2 + 1) = 3 = 3 * 1
24 = 3 * 8; (2 + 4) = 6 = 3 * 2
27 = 3 * 9; (2 + 7) = 9 = 3 * 3
30 = 3 * 10; (3 + 0) = 3 = 3 * 1
33 = 3 * 11; (3 + 3) = 6 = 3 * 2
36 = 3 * 12; (3 + 6) = 9 = 3 * 3
...
99 = 3 * 33; (9 + 9) = 18 = 3 * 6
...
2274 = 3 * 758; (2 + 2 + 7 + 4) = 15 = 3 * 5
...

2 digits

Let's say the natural number X is 2 digits. X can be expressed as the following using natural number a and b. In this case, a summary of each digit is a + b.

X = a + b * 10

And the number X can be written as following using another natural number Y.

X = 3 * Y

Conbining the 2 equisitions.

a + b * 10 = 3 * Y
a + b * (1 + 9) = 3 * Y
a + b * 1 + b * 9 = 3 * Y
            ~~~~~ move to right side
a + b = 3 * Y - b * 9
              ~~~~~~~
      = 3 * Y - b * 3 * 3
        ~~~           ~~~
      = 3 * (Y - b * 3)

i.e., If the number X is a multiple of 3, the sum of each digit number (a + b) is multiple of 3.

Let's move to multiple digits of X.

Multiple digits

Let's say there is a number X which is multiple digits and is a multiple of 3. The number X can be expressed as the following equation. In this case the summary of each digit of X is a + b + c + d + ....

X = a + b * 10 + c * 100 + d * 1000 + ...
        ~~~~~~   ~~~~~~~   ~~~~~~~~
  = a + b * (1 + 9) + c * (1 + 99) + d * (1 + 999) + ...
        ~~~~~~~~~~~   ~~~~~~~~~~~~   ~~~~~~~~~~~~~   ~~~
  = a + b + c + d + ... + b * 9 + c * 99 + d * 999 + ...
        ~~~~~~~~~~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  = a + b + c + d + ... + b * 9 + c * 9 * 11 + d * 9 * 111 + ...
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  = a + b + c + d + ... + 9 * (b + c * 11 + d * 111 + ...)
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

By the way, the number X is a multiple of 3, X can be expressed as the following equation with an integer Y.

X = 3 * Y

The above 2 equations are identical.

a + b + c + d + ... + 9 * (b + c * 11 + d * 111 + ...) = 3 * Y

Transforming the above equation to leave a summary of each digit left side, the right side of the equation is a multiple of 3.

a + b + c + d + ... + 9 * (b + c * 11 + d * 111 + ...) = 3 * Y
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ move to right side
a + b + c + d + ... = 3 * Y - 9 * (b + c * 11 + d * 111 + ...)
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                    = 3 * Y - 3 * 3 * (b + c * 11 + d * 111 + ...)
                      ~~~     ~~~
                    = 3 * (Y - 3 * (b + c * 11 + d * 111 + ...))
                      ~~~

i.e., If the number X is multiple of 3, a summary of each digit of X is multiple of 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment