noxz-sites

A collection of a builder and various scripts creating the noxz.tech sites
git clone https://noxz.tech/git/noxz-sites.git
Log | Files | README | LICENSE

noxz.tech/articles/divisibility_theorems_and_fraction_flipping/index.www
1.\".fam C
2
3.DIVS toc
4.SPAN toc-title Contents
5.ULS
6.LI
71
8.URL #math-div-theorems "Divisibility theorems"
9.ULS
10.LI
111.1
12.URL #math-div-theorems-1 "Divisibility by 1"
13.LI
141.2
15.URL #math-div-theorems-2 "Divisibility by 2"
16.LI
171.3
18.URL #math-div-theorems-3 "Divisibility by 3"
19.LI
201.4
21.URL #math-div-theorems-4 "Divisibility by 4"
22.LI
231.5
24.URL #math-div-theorems-5 "Divisibility by 5"
25.LI
261.6
27.URL #math-div-theorems-6 "Divisibility by 6"
28.LI
291.7
30.URL #math-div-theorems-7 "Divisibility by 7"
31.LI
321.8
33.URL #math-div-theorems-8 "Divisibility by 8"
34.LI
351.9
36.URL #math-div-theorems-9 "Divisibility by 9"
37.LI
381.10
39.URL #math-div-theorems-10 "Divisibility by 10"
40.LI
411.11
42.URL #math-div-theorems-11 "Divisibility by 11"
43.LI
441.13
45.URL #math-div-theorems-13 "Divisibility by 13"
46.LI
471.17
48.URL #math-div-theorems-17 "Divisibility by 17"
49.ULE
50.LI
512
52.URL #math-rec-div-alg "Recursive divisibility algorithms"
53.ULS
54.LI
552.1
56.URL #math-rev-div-alg-script "Python script for finding recursive divisibility algorithms"
57.LI
582.2
59.URL #math-rev-div-alg-find "Finding all divisibility algorithms for primes"
60.HnE
61.LI
622.3
63.URL #math-rev-div-alg-alt "Alternative way of deriving recursive divisibility algorithms"
64.ULE
65.LI
663
67.URL #math-fractions "Fractions"
68.ULS
69.LI
703.1
71.URL #math-fractions-flip "The fraction flip when dividing"
72.ULE
73.ULH
74.DIVE
75
76.HnS 1
77.TAG "math-div-theorems"
78Divisibility theorems
79.HnE
80
81When it comes to divisibility, there exist some neat theorems to test a certain
82number’s different divisibilities, or factors. The following are those theorems
83and their proofs. Some of the proofs are more trivial than others, such as the
84proof for divisibility by 1, 2, 5, and 10. From here on out, it’s assumed that
85every number, when working with divisibility, is an integer.
86
87What is the smallest number that is divisible by 1 through 10? The answer is
88.SPAN spoiler 2520 .
89You can try the different divisibility theorems below to prove it.
90
91.HnS 2
92.TAG "math-div-theorems-1"
93Divisibility by 1
94.HnE
95
96This theorem is quite easy to remember. Every integer is divisible by 1.
97
98.DIVS theorem
99.TEXS
100\[ 1 \mid a \iff a \in \mathbb{Z} \]
101.TEXE
102.DIVE
103
104.HnS 2
105.TAG "math-div-theorems-2"
106Divisibility by 2
107.HnE
108It's common knowledge that every even number (numbers ending with an even
109number) is divisible by 2. This is because even numbers are multiples of 2. In
110short, if a number ends with either 0, 2, 4, 6, or 8, it is divisible by 2.
111
112Say we have a four-digit number
113.I abcd ,
114where
115.I a
116represents the number of thousands,
117.I b
118the number of hundreds,
119.I c
120the number of tens, and the number
121.I d .
122This number can be represented as
123.I a "" 1000
124+
125.I b "" 100
126+
127.I c "" 10
128+
129.I d .
130If
131.I d
132is divisible by 2, we can represent it as an even number
133.I n , 2
134like so:
135
136.TEXS
137\begin{align*}
138&1000a + 100b + 10c + 2n
139\\
140&2 \left( 500a + 50b + 5c + n \right)
141\end{align*}
142.TEXE
143
144We can now see that the number is divisible by 2 if, and only if, the last
145digit is divisible by 2. And so the theorem is proven.
146
147.DIVS theorem
148.TEXS
149\[ 2 \mid abcd \iff 2 \mid d \]
150.TEXE
151.DIVE
152
153.HnS 2
154.TAG "math-div-theorems-3"
155Divisibility by 3
156.HnE
157The theorem goes that if the sum of all digits in a number is divisible by 3,
158the whole number is divisible by 3, i.e.
159
160.TEXS
161\[ 3 \mid abcd \iff 3 \mid \left( a + b + c + d \right) \]
162.TEXE
163
164Why is this proposition true?
165
166Let's use the four-digit number
167.I abcd ,
168where
169.I a
170represents the number of thousands,
171.I b
172the number of hundreds,
173.I c
174the number of tens, and the number
175.I d .
176This number can be represented as
177.I a "" 1000
178+
179.I b "" 100
180+
181.I c "" 10
182+
183.I d .
184Now let's break out one
185.I a ,
186.I b ,
187and
188.I c
189from the first 3 terms, and factor out 3 like so:
190
191.TEXS
192\begin{align*}
193& 1000a + 100b + 10c + d
194\\
195& \left( 999a + 99b + 9c \right) + \left( a + b + c + d \right)
196\\
197& 3 \left( 333a + 33b + 3c \right) + \left( a + b + c + d \right)
198\end{align*}
199.TEXE
200
201We can now see that the first term is divisible by 3, and the second term is
202divisible by 3 if, and only if, the sum of
203.I a
204+
205.I b
206+
207.I c
208+
209.I d
210is divisible by 3. And so the theorem is proven.
211
212.DIVS theorem
213.TEXS
214\[ 3 \mid abcd \iff 3 \mid \left( a + b + c + d \right) \]
215.TEXE
216.DIVE
217
218We have shown that the procedure above will hold for all cases. The procedure
219is also recursive. If the sum is too hard to test for divisibility, the
220procedure can be repeated until a smaller sum is revealed. This is rarely
221necessary as the divisibility of the sum is often easy to determine.
222
223.HnS 2
224.TAG "math-div-theorems-4"
225Divisibility by 4
226.HnE
227The theorem goes that if the last two digits of a number are divisible by 4,
228the whole number is divisible by 4, i.e.
229
230.TEXS
231\[ 4 \mid abcd \iff 4 \mid cd \]
232.TEXE
233
234Why is this proposition true?
235
236Let's use the four-digit number
237.I abcd ,
238where
239.I a
240represents the number of thousands,
241.I b
242the number of hundreds,
243.I c
244the number of tens, and the number
245.I d .
246This number can be represented as
247.I a "" 1000
248+
249.I b "" 100
250+
251.I c "" 10
252+
253.I d .
254Now let's factor out 4 from the first two terms, like so:
255
256.TEXS
257\begin{align*}
258&1000a + 100b + 10c + d
259\\
260&4 \left( 250a + 25b \right) + \left( 10c + d \right)
261\end{align*}
262.TEXE
263
264We can now see that the first term is divisible by 4, so the whole number is
265divisible by 4 if, and only if, the second term is divisible by 4. And so the
266theorem is proven.
267
268.DIVS theorem
269.TEXS
270\[ 4 \mid abcd \iff 4 \mid cd \]
271.TEXE
272.DIVE
273
274.HnS 2
275.TAG "math-div-theorems-5"
276Divisibility by 5
277.HnE
278The theorem goes that if the last digits of a number are divisible by 5, the
279whole number is divisible by 5, i.e.
280
281.TEXS
282\[ 5 \mid abcd \iff 5 \mid d \]
283.TEXE
284
285Why is this proposition true?
286
287Let's use the four-digit number
288.I abcd ,
289where
290.I a
291represents the number of thousands,
292.I b
293the number of hundreds,
294.I c
295the number of tens, and the number
296.I d .
297This number can be represented as
298.I a "" 1000
299+
300.I b "" 100
301+
302.I c "" 10
303+
304.I d .
305Now let's factor out 5 from the first three terms, like so:
306
307.TEXS
308\begin{align*}
309&1000a + 100b + 10c + d
310\\
311&5 \left( 500a + 50b + 5c \right) + d
312\end{align*}
313.TEXE
314
315We can now see that the first term is divisible by 5, so the whole number is
316divisible by 5 if, and only if, the second term is divisible by 5. And so the
317theorem is proven. As the only one-digit numbers that are divisible by 5 are 0
318and 5, another way of putting it is that if the last digit is 0 or 5, the
319number is divisible by 5.
320
321.DIVS theorem
322.TEXS
323\[ 5 \mid abcd \iff 5 \mid d \]
324.TEXE
325.DIVE
326
327.HnS 2
328.TAG "math-div-theorems-6"
329Divisibility by 6
330.HnE
331This theorem is a combination of the theorem for
332.URL #math-div-theorems-2 "divisibility by 2"
333and
334.URL #math-div-theorems-3 "divisibility by 3" .
335
336.DIVS theorem
337.TEXS
338\[ 6 \mid abcd \iff 3 \mid \left( a + b + c + d \right) \land 2 \mid d \]
339.TEXE
340.DIVE
341
342.B Note :
343Be careful when combining theorems like this. Don't be fooled and try to
344combine the divisibility theorems for 2 and 4 to get the theorem for 8, as
345numbers divisible by 4 are always divisible by 2. The number 4 is, for
346instance, both divisible by 2 and by 4, but
347.I not
348by 8. Make sure the theorems you combine
349doesn't share a factor, like 4 and 2 sharing factor 2. It's, of course,
350possible to use theorems 4 and 2 together, but it's not certain in all cases
351that the two theorems prove divisibility by 8.
352
353.HnS 2
354.TAG "math-div-theorems-7"
355Divisibility by 7
356.HnE
357Probably one of the most useful theorems is the theorem of
358.I "divisibility by 7" ,
359as it is recursive (just like the theorems of
360.I "divisibility by 3 & 9" ).
361The theorem states that if the difference between the last digit multiplied by
3622 and the remaining digits in a number is divisible by 7, the whole number is
363divisible by 7. I'll show you the procedure with an example below:
364
365.TEXS
366\begin{align*}
367&7 \stackrel{?}{\mid} 3423
368\\
369&342 - 3 \times 2   &= 336
370\\
371&33 - 6 \times 2    &= 21
372\\
373&7 \mid 21          &\Rightarrow 7 \mid 3423
374\end{align*}
375.TEXE
376
377Neat! So how and why does it work? For simplicity's sake, we use a two-digit
378number
379.I ab ,
380represented as
381.I a "" 10
382+
383.I b .
384The theorem says that if
385.B A ) (
3867 |
387.I a
388-
389.I b "" 2
390then
391.B B ) (
3927 |
393.I a "" 10
394+
395.I b .
396Let's prove it!
397
398In order to prove the theorem, we must prove both
399.B A
400and
401.B B .
402So let's start with
403.B A .
404If we have
405.I a
406-
407.I b , 2
408and it's divisible by 7, we know that 7 must be a factor of the
409expression. We can now create an equation.
410
411.TEXS
412\[ a - 2b = 7k \]
413.TEXE
414
415Multiply the whole equation by 10, and add one extra
416.I b :
417
418.TEXS
419\begin{align*}
420\hi{10}a - \hi{20}b = \hi{70}k
421\\
42210a - 20b \hi{+ b} = 70k \hi{+ b}
423\\
42410a - \hi{19b} = 70k + b
425\end{align*}
426.TEXE
427
428Now add
429.I b "" 20
430to each side of the equation, and try to factor out 7:
431
432.TEXS
433\begin{align*}
43410a - 19b \hi{+ 20b} = 70k + b \hi{+ 20b}
435\\
43610a \hi{+ b} = 70k \hi{+ 21b}
437\\
43810a + b = \hi{7 \left( 10k + 3b \right)}
439\end{align*}
440.TEXE
441
442We can now see that the right side of the equation is divisible by 7, and our
443left side says
444.I a "" 10
445+
446.I b .
447Neat, we now know that the two-digit number
448.I ab
449is divisible by 7. Now we must show that
450.B B
451implies
452.B A .
453That is, if
454.I a
455-
456.I b "" 2
457is divisible by 7, then
458.I a "" 10
459+
460.I b
461is divisible by 7. Let's prove
462.B B .
463
464Just as for
465.B A ,
466we know that 7 must be a factor of the expression. We can
467now create another equation:
468
469.TEXS
470\[ 10a + b = 7k \]
471.TEXE
472
473Subtract
474.I b "" 21
475from the whole equation, and factorize:
476
477.TEXS
478\begin{align*}
47910a + b \hi{- 21b} = 7k \hi{- 21b}
480\\
48110a \hi{- 20b} = 7k - 21b
482\\
483\hi{10 \left( a - 2b \right) } = \hi{7 \left( k - 3b \right) }
484\end{align*}
485.TEXE
486
487We can now see that the right side of the equation is divisible by 7, and on
488our left hand, 10 is not divisible by 7, so the expression inside the
489parenthesis must be. But isn't that expression
490.I a
491-
492.I b ? 2
493We now have the proof for the theorem and can conclude that, indeed,
494
495.DIVS theorem
496.TEXS
497\[ 7 \mid ab \iff 7 \mid a - 2b \]
498.TEXE
499.DIVE
500
501We have shown that the procedure above will hold for all cases.
502
503.HnS 2
504.TAG "math-div-theorems-8"
505Divisibility by 8
506.HnE
507The theorem is quite similar to the theorem for
508.URL #math-div-theorems-4 "divisibility by 4" .
509The theorem goes that if the last three digits of a number are divisible by 8,
510then the whole number is divisible by 8, i.e.
511
512.TEXS
513\[ 8 \mid abcd \iff 8 \mid bcd \]
514.TEXE
515
516Why is this proposition true?
517
518Let's use the four-digit number
519.I abcd ,
520where
521.I a
522represents the number of thousands,
523.I b
524the number of hundreds,
525.I c
526the number of tens, and the number
527.I d .
528This number can be represented as
529.I a "" 1000
530+
531.I b "" 100
532+
533.I c "" 10
534+
535.I d .
536Now let's factor out 8 from the first term, like so,
537
538.TEXS
539\begin{align*}
5401000a + 100b + 10c + d
541\\
5428 \left( 125a \right) + \left( 100b + 10c + d \right)
543\end{align*}
544.TEXE
545
546We can now see that the first term is divisible by 8, so the whole number is
547divisible by 8 if, and only if, the second term is divisible by 8. And so the
548theorem is proven.
549
550.DIVS theorem
551.TEXS
552\[ 8 \mid abcd \iff 8 \mid bcd \]
553.TEXE
554.DIVE
555
556.HnS 2
557.TAG "math-div-theorems-9"
558Divisibility by 9
559.HnE
560Much like the theorem for
561.URL #math-div-theorems-3 "divisibility by 3" ,
562the theorem goes that if the sum of all digits in a number is divisible by 9,
563the whole number is divisible by 9, i.e.,
564
565.TEXS
566\[ 9 \mid abcd \iff 9 \mid \left( a + b + c + d \right) \]
567.TEXE
568
569Why is this proposition true?
570
571Let's use the four-digit number
572.I abcd ,
573where
574.I a
575represents the number of thousands,
576.I b
577the number of hundreds,
578.I c
579the number of tens, and the number
580.I d .
581This number can be represented as
582.I a "" 1000
583+
584.I b "" 100
585+
586.I c "" 10
587+
588.I d .
589Now let's break out one a, b, and c from the first 3 terms, and factor out 9
590like so:
591
592.TEXS
593\begin{align*}
5941000a + 100b + 10c + d
595\\
596\left( 999a + 99b + 9c \right) + \left( a + b + c + d \right)
597\\
5989 \left( 111a + 11b + 1c \right) + \left( a + b + c + d \right)
599\end{align*}
600.TEXE
601
602We can now see that the first term is divisible by 9, and the second term is
603divisible by 9 if, and only if, the sum of
604.I a
605+
606.I b
607+
608.I c
609+
610.I d
611is divisible by 9. And so the theorem is proven.
612
613.DIVS theorem
614.TEXS
615\[ 9 \mid abcd \iff 9 \mid \left( a + b + c + d \right) \]
616.TEXE
617.DIVE
618
619We have shown that the procedure above will hold for all cases. The procedure
620is also recursive. If the sum is too hard to test for divisibility, the
621procedure can be repeated until a smaller sum is revealed. This is rarely
622necessary as the divisibility of the sum is often easy to determine.
623
624.HnS 2
625.TAG "math-div-theorems-10"
626Divisibility by 10
627.HnE
628The theorem goes that if the last digits of a number are divisible by 10, the
629whole number is divisible by 10, i.e.
630
631.TEXS
632\[ 10 \mid abcd \iff 10 \mid d \]
633.TEXE
634
635Why is this proposition true?
636
637Let's use the four-digit number
638.I abcd ,
639where
640.I a
641represents the number of thousands,
642.I b
643the number of hundreds,
644.I c
645the number of tens, and the number
646.I d .
647This number can be represented as
648.I a "" 1000
649+
650.I b "" 100
651+
652.I c "" 10
653+
654.I d .
655Now let's factor out 10 from the first three terms, like so:
656
657.TEXS
658\begin{align*}
6591000a + 100b + 10c + d
660\\
66110 \left( 100a + 10b + c \right) + d
662\end{align*}
663.TEXE
664
665We can now see that the first term is divisible by 10, so the whole number is
666divisible by 10 if, and only if, the second term is divisible by 10. And so the
667theorem is proven. As the only one-digit number that is divisible by 10 is 0,
668another way of putting it is that if the last digit is 0, the number is
669divisible by 10.
670
671.DIVS theorem
672.TEXS
673\[ 10 \mid abcd \iff 10 \mid d \]
674.TEXE
675.DIVE
676
677.HnS 2
678.TAG "math-div-theorems-11"
679Divisibility by 11
680.HnE
681The theorem goes that a number is divisible by 11 if, and only if, the
682alternate sum of its digits is divisible by 11. Like so,
683
684.TEXS
685\begin{align*}
68611 \stackrel{?}{\mid} 190905
687\\
6881 - 9 + 0 - 9 + 0 - 5 = -22
689\\
69011 \mid -22 \Rightarrow 11 \mid 190905
691\end{align*}
692.TEXE
693
694Neat! So how and why does it work? For simplicity's sake, we use a four-digit
695number
696.I abcd ,
697where
698.I a
699represents the number of thousands,
700.I b
701the number of hundreds,
702.I c
703the number of tens, and the number
704.I d .
705This number can be represented as
706.I a "" 1000
707+
708.I b "" 100
709+
710.I c "" 10
711+
712.I d .
713This expression can also be represented in another way by manipulating
714the terms. We give and take in an alternating fashion, like so:
715
716.TEXS
717\begin{align*}
7181000a + 100b + 10c + d
719\\
720\hi{ a \left( 1000 \right) } +
721\hi{ b \left( 100 \right) } +
722\hi{ c \left( 10 \right) } + d
723\\
724a \left( \hi{ 1001 - 1 } \right) +
725b \left( \hi{ 99 + 1 } \right) +
726c \left( \hi{ 11 - 1 } \right) + d
727\\
728\hi{ 1001a - a } +
729\hi{ 99b + b } +
730\hi{ 11c - c} + d
731\\
7321001a \hi{ + 99b + 11c - a + b} - c + d
733\end{align*}
734.TEXE
735
736Now we factorize the expression, like so:
737
738.TEXS
739\[ \hi{ 11 \left( 91a + 9b + c \right) } - a + b - c + d \]
740.TEXE
741
742We can see that the first term in the expression is divisible by 11. This means
743that if, and only if, the sum of the other terms is divisible by 11, then the
744whole expression is divisible by 11, and so the theorem is proven.
745
746.DIVS theorem
747.TEXS
748\begin{align*}
749{ 11 \mid abcd \iff 11 \mid -a + b - c + d }
750\\
751{ 11 \mid abcd \iff 11 \mid a - b + c - d }
752\end{align*}
753.TEXE
754.DIVE
755
756We have shown that the procedure above will hold for all cases, as the number
757can be extended with infinite digits and still follow the same pattern.
758
759.HnS 2
760.TAG "math-div-theorems-13"
761Divisibility by 13
762.HnE
763Just like the theorem of divisibility by 7,
764the theorem of
765.I "divisibility by 13" ,
766is recursive.
767The theorem states that if the sum of the last digit multiplied by
7684 and the remaining digits in a number is divisible by 13, the whole number is
769divisible by 13. I'll show you the procedure with an example below:
770
771.TEXS
772\begin{align*}
773{ 13 \stackrel{?}{\mid} 76752 }
774\\
775{ 7675 + 2 \times 4 = 7683 }
776\\
777{ 768 + 3 \times 4 = 780 }
778\\
779{ 78 + 0 \times 4 = 78 }
780\\
781{ 7 + 8 \times 4 = 39 }
782\\
783{ 13 \mid 39 \Rightarrow 13 \mid 76752 }
784\end{align*}
785.TEXE
786
787Neat! So how and why does it work? For simplicity's sake, we use a two-digit
788number
789.I ab ,
790represented as
791.I a "" 10
792+
793.I b .
794The theorem says that if
795.B A ) (
79613 |
797.I a
798+
799.I b "" 4
800then
801.B B ) (
80213 |
803.I a "" 10
804+
805.I b .
806Let's prove it!
807
808In order to prove the theorem, we must prove both
809.B A
810and
811.B B .
812So let's start with
813.B A .
814If we have
815.I a
816+
817.I b , 4
818and it's divisible by 13, we know that 13 must be a factor of the
819expression. We can now create an equation.
820
821.TEXS
822\[
823a + 4b = 13k
824\]
825.TEXE
826
827Multiply the whole equation by 10, and add one extra
828.I b :
829
830.TEXS
831\begin{align*}
832{ \hi{10}a + \hi{40}b = \hi{130}k }
833\\
834{ 10a + 40b \hi{+ b} = 130k \hi{+ b} }
835\\
836{ 10a + \hi{41b} = 130k + b }
837\end{align*}
838.TEXE
839
840Now subtract
841.I b "" 40
842from each side of the equation, and try to factor out 13:
843
844.TEXS
845\begin{align*}
846{ 10a + 41b \hi{- 40b} = 130k + b \hi{- 40b} }
847\\
848{ 10a \hi{+ b} = 130k \hi{- 39b} }
849\\
850{ 10a + b = \hi{13 \left( 10k - 3b \right)} }
851\end{align*}
852.TEXE
853
854We can now see that the right side of the equation is divisible by 13, and our
855left side says
856.I a "" 10
857+
858.I b .
859Neat, we now know that the two-digit number
860.I ab
861is divisible by 13. Now we must show that
862.B B
863implies
864.B A .
865That is, if
866.I a
867+
868.I b "" 4
869is divisible by 13, then
870.I a "" 10
871+
872.I b
873is divisible by 13. Let's prove
874.B B .
875
876Just as for
877.B A ,
878we know that 13 must be a factor of the expression. We can
879now create another equation:
880
881.TEXS
882{ 10a + b = 13k }
883.TEXE
884
885Add
886.I b "" 39
887to both sides of the equation, and factorize:
888
889.TEXS
890\begin{align*}
891{ 10a + b \hi{+ 39b} = 13k \hi{+ 39b} }
892\\
893{ 10a \hi{+ 40b} = 13k + 39b }
894\\
895{ \hi{10 \left( a + 4b \right) } = \hi{13 \left( k + 3b \right) } }
896\end{align*}
897.TEXE
898
899We can now see that the right side of the equation is divisible by 13, and on
900our left hand, 10 is not divisible by 13, so the expression inside the
901parenthesis must be. But isn't that expression
902.I a
903+
904.I b ? 4
905We now have the proof for the theorem and can conclude that, indeed,
906
907.DIVS theorem
908.TEXS
909\[
91013 \mid ab \iff 13 \mid a + 4b
911\]
912.TEXE
913.DIVE
914
915We have shown that the procedure above will hold for all cases.
916
917.HnS 2
918.TAG "math-div-theorems-17"
919Divisibility by 17
920.HnE
921Just like the theorem of divisibility by 7 and 13,
922the theorem of
923.I "divisibility by 17" ,
924is recursive.
925The theorem states that if the difference between last digit multiplied by
9265 and the remaining digits in a number is divisible by 17, the whole number is
927divisible by 17. I'll show you the procedure with an example below:
928
929.TEXS
930\begin{align*}
931{ 17 \stackrel{?}{\mid} 206091 }
932\\
933{ 20609 - 1 \times 5 = 20604 }
934\\
935{ 2060 - 4 \times 5 = 2040 }
936\\
937{ 204 - 0 \times 5 = 204 }
938\\
939{ 20 - 4 \times 5 = 0 }
940\\
941{ 17 \mid 0 \Rightarrow 17 \mid 206091 }
942\end{align*}
943.TEXE
944
945If you are not satisfied with 0 being the numerator, here is another example:
946
947.TEXS
948\begin{align*}
949{ 17 \stackrel{?}{\mid} 2057 }
950\\
951{ 205 - 7 \times 5 = 170 }
952\\
953{ 17 - 0 \times 5 = 17 }
954\\
955{ 17 \mid 17 \Rightarrow 17 \mid 2057 }
956\end{align*}
957.TEXE
958
959Neat! So how and why does it work? For simplicity's sake, we use a two-digit
960number
961.I ab ,
962represented as
963.I a "" 10
964+
965.I b .
966The theorem says that if
967.B A ) (
96817 |
969.I a
970-
971.I b "" 5
972then
973.B B ) (
97417 |
975.I a "" 10
976+
977.I b .
978Let's prove it!
979
980In order to prove the theorem, we must prove both
981.B A
982and
983.B B .
984So let's start with
985.B A .
986If we have
987.I a
988-
989.I b , 5
990and it's divisible by 17, we know that 17 must be a factor of the
991expression. We can now create an equation.
992
993.TEXS
994\[
995a - 5b = 17k
996\]
997.TEXE
998
999Multiply the whole equation by 10, and add one extra
1000.I b :
1001
1002.TEXS
1003\begin{align*}
1004{ \hi{10}a - \hi{50}b = \hi{170}k }
1005\\
1006{ 10a - 50b \hi{+ b} = 170k \hi{+ b} }
1007\\
1008{ 10a - \hi{49b} = 170k + b }
1009\end{align*}
1010.TEXE
1011
1012Now add
1013.I b "" 50
1014to each side of the equation, and try to factor out 17:
1015
1016.TEXS
1017\begin{align*}
1018{ 10a - 49b \hi{+ 50b} = 170k + b \hi{+ 50b} }
1019\\
1020{ 10a \hi{+ b} = 170k \hi{+ 51b} }
1021\\
1022{ 10a + b = \hi{17 \left( 10k + 3b \right)} }
1023\end{align*}
1024.TEXE
1025
1026We can now see that the right side of the equation is divisible by 17, and our
1027left side says
1028.I a "" 10
1029+
1030.I b .
1031Neat, we now know that the two-digit number
1032.I ab
1033is divisible by 17. Now we must show that
1034.B B
1035implies
1036.B A .
1037That is, if
1038.I a
1039-
1040.I b "" 5
1041is divisible by 17, then
1042.I a "" 10
1043+
1044.I b
1045is divisible by 17. Let's prove
1046.B B .
1047
1048Just as for
1049.B A ,
1050we know that 17 must be a factor of the expression. We can
1051now create another equation:
1052
1053.TEXS
1054\[
105510a + b = 17k
1056\]
1057.TEXE
1058
1059Subtract
1060.I b "" 51
1061from both sides of the equation, and factorize:
1062
1063.TEXS
1064\begin{align*}
1065{ 10a + b \hi{- 51b} = 17k \hi{- 51b} }
1066\\
1067{ 10a \hi{- 50b} = 17k + 51b }
1068\\
1069{ \hi{10 \left( a - 5b \right) } = \hi{17 \left( k - 3b \right) } }
1070\end{align*}
1071.TEXE
1072
1073We can now see that the right side of the equation is divisible by 17, and on
1074our left hand, 10 is not divisible by 17, so the expression inside the
1075parenthesis must be. But isn't that expression
1076.I a
1077-
1078.I b ? 5
1079We now have the proof for the theorem and can conclude that, indeed,
1080
1081.DIVS theorem
1082.TEXS
1083\[
108417 \mid ab \iff 17 \mid a - 5b
1085\]
1086.TEXE
1087.DIVE
1088
1089We have shown that the procedure above will hold for all cases.
1090
1091.HnS 1
1092.TAG "math-rec-div-alg"
1093Recursive divisibility algorithms
1094.HnE
1095As you might have noticed, there are some divisibility rules that are quite
1096similar. The rules for divisibility by 7, 13, and 17 are all based on a
1097recursive algorithm in which the last digit is multiplied by a certain number
1098and then either added to or subtracted from the number represented by the
1099remaining digits. Similar to this
1100
1101.TEXS
1102\[
1103abcd \rightarrow abc + d \times n
1104\]
1105.TEXE
1106
1107where
1108.I n
1109represents the number that is multiplied by the last digit
1110.I d .
1111In the theorems proven above, the rules for divisibility by 7, 13 and 17 could
1112be summarized like so:
1113
1114.TEXS
1115\begin{align*}
1116{7 \mid abcd \iff 7 \mid  abc -2 \times d}
1117\\
1118{13 \mid abcd \iff 13 \mid  abc +4 \times d}
1119\\
1120{17 \mid abcd \iff 17 \mid  abc -5 \times d}
1121\end{align*}
1122.TEXE
1123
1124Except for
1125.I n
1126being different in each algorithm, they are all the same. They could, in fact,
1127be summarized even shorter by only stating the divisor and the number
1128.I n
1129in this way:
1130
1131.CDS
1132.COS
11337: -2
113413: +4
113517: -5
1136.COE
1137.CDE
1138
1139Divisibility by 11 could also be tested in this manner by having
1140.I n
1141= -1. However, the
1142.URL #math-div-theorems-11 rule
1143of alternating subtraction and addition between the digits in a number is much
1144more effective than using the recursive algorithm for testing divisibility by
114511.
1146
1147There are, in fact, multiple divisibility rules that can be constructed using
1148the recursive algorithm by only changing the number
1149.I n .
1150I have written a short Python script that finds all recursive divisibility
1151rules along with their corresponding
1152.I n .
1153However, I haven’t ensured that all the rules found actually work in all cases;
1154there could be false positives. They would need to be proven algebraically
1155first. The ones I have proven to be correct, including 11, are:
1156
1157.CDS
1158.COS
11597: -2
116011: -1
116113: +4
116217: -5
1163.COE
1164.CDE
1165
1166Before you think that the pattern is connected to prime numbers, try the
1167algorithm with divisibility by 27 using
1168.I n
1169= -8. The next working number after 27 is, in fact, 29, and all prime numbers
1170are included. There are in fact some other interesting patterns...
1171
1172.HnS 2
1173.TAG "math-rev-div-alg-script"
1174Python script for finding recursive divisibility algorithms
1175.HnE
1176
1177If you would like to discover and prove the remaining ones, as I have done for
11787, 13, and 17, you can try using this Python script:
1179
1180.CDS
1181.COS
1182#!/usr/bin/env python3
1183
1184# find all recursive divisibility algorithms from 1 through 99
1185for div in range(1, 100):
1186
1187	# test all recursive additions from 2 up to the div
1188	for n in range(2, div):
1189
1190		# create a large number with div as a known factor
1191		num = div * 123456789123456
1192
1193		# perform recursive calculations while number is divisible by the div
1194		while num % div == 0 and num > div:
1195			# keep track of the previous number
1196			prev = num
1197
1198			# perform recursive calculation (abcd -> abc + d*n)
1199			num = int(str(num)[:-1]) + int(str(num)[-1]) * n
1200
1201			# break on infinite loop
1202			if (prev == num or prev == div):
1203				break
1204
1205		# make last check to see if the number is divisible by the div
1206		if (num % div == 0):
1207
1208			# use the smallest (disregarding if it's negative or positive)
1209			# number in the recursive calculations.
1210			# this means that there is always to ways to perform the recursive
1211			# calculations, either by addition or by subtraction
1212			#
1213			# ex: 13: abcd -> abc -9d or abc +4d
1214			# in this example 4 < 9, so 4 is the smallest
1215			if (div - n < n):
1216				n -= div
1217			print("{:d}: {:+d}".format(div, n))
1218			break
1219.COE
1220.CDE
1221
1222When running the script, you might discover some interesting patterns from 11
1223and up:
1224
1225.CDS
1226.COS
1227        1 --->    11: -1     |-
1228        3 |       13: +4               <---
1229   +10  7 |       17: -5         <--      |
1230        9 |       19: +2     |+    |      | +3
1231        1 --->    21: -2     |-    | -3   |
1232        3 |       23: +7           |   <---
1233   +10  7 |       27: -8         <--      |
1234        9 |       29: +3     |+    |      | +3
1235        1 --->    31: -3     |-    | -3   |
1236        3 |       33: +10          |   <---
1237   +10  7 |       37: -11        <--      |
1238        9 |       39: +4     |+    |      | +3
1239        1 --->    41: -4     |-    | -3   |
1240        3 |       43: +13          |   <---
1241   +10  7 |       47: -14        <--      |
1242        9 |       49: +5     |+    |      | +3
1243        1 --->    51: -5     |-    | -3   |
1244        3 |       53: +16          |   <---
1245   +10  7 |       57: -17        <--      |
1246        9 |       59: +6     |+    |      | +3
1247        1 --->    61: -6     |-    | -3   |
1248        3 |       63: +19          |   <---
1249   +10  7 |       67: -20        <--      |
1250        9 |       69: +7     |+    |      | +3
1251        1 --->    71: -7     |-    | -3   |
1252        3 |       73: +22          |   <---
1253   +10  7 |       77: -23        <--      |
1254        9 |       79: +8     |+    |      | +3
1255        1 --->    81: -8     |-    | -3   |
1256        3 |       83: +25          |   <---
1257   +10  7 |       87: -26        <--      |
1258        9 |       89: +9     |+    |      | +3
1259        1 --->    91: -9     |-    | -3   |
1260        3 |       93: +28          |   <---
1261        7 |       97: -29        <--
1262        9 |       99: +10    |+
1263.COE
1264.CDE
1265
1266Even if the script won't output 3 and 9, they do follow the same pattern.
1267And the same could technically be said about 1. So, the pattern actually starts
1268at 1 and continues into infinity. And as all prime numbers end with either 1,
12693, 7 or 9, except for 2 and 5, all prime numbers are included. This is a known
1270sequence:
1271.URL https://oeis.org/A333448 https://oeis.org/A333448
1272
1273.HnS 2
1274.TAG "math-rev-div-alg-find"
1275Finding all divisibility algorithms for primes
1276.HnE
1277Based on the output from the script and the knowledge about all primes being
1278included, except for 2 and 5, we could construct a short list of everything we
1279need to find out if a number is divisible by any prime number.
1280
1281What we need:
1282.OLS
1283.LI
1284The divisibility rule for the prime number 2: is the last digit an even number?
1285
1286.TEXS
1287\[
12882 \mid abcd \iff 2 \mid d
1289\]
1290.TEXE
1291
1292.LI
1293The divisibility rule for the prime number 5: is the last digit a 5 or a 0?
1294
1295.TEXS
1296\[
12975 \mid abcd \iff 5 \mid d
1298\]
1299.TEXE
1300
1301.LI
1302A general rule for any number with the last digit being 1, 3, 7 or 9, including
1303the rest of all prime numbers:
1304
1305.TEXS
1306\[
1307n \mid abcd \iff n \mid abc + D(n) \times d
1308\]
1309.TEXE
1310
1311.LI
1312A way to calculate D(n):
1313
1314.TEXS
1315\begin{align*}
1316D(n) =
1317\begin{cases}
13189a + 1, & \text{if } n = 10a + 1 \\
13193a + 1, & \text{if } n = 10a + 3 \\
13207a + 5, & \text{if } n = 10a + 7 \\
1321a + 1,  & \text{if } n = 10a + 9
1322\end{cases}
1323\end{align*}
1324.TEXE
1325
1326If we want a small number,
1327.I D(n) ,
1328to add or subtract:
1329
1330.TEXS
1331\begin{align*}
1332D_{s}(n) =
1333\begin{cases}
1334D(n) - n, & \text{if } n - D(n) < D(n) \\
1335D(n), & \text{otherwise}
1336\end{cases}
1337\end{align*}
1338.TEXE
1339.OLE
1340
1341Example, get the divisibility algorithm for the prime number 71:
1342
1343.TEXS
1344\begin{align*}
1345{ D(71) = 9 \times 7 + 1 = 64 }
1346\\
1347{ D_{s}(n) = 64 - 71 = -7 }
1348\\
1349{ \Rightarrow 71 \mid abcd \iff 71 \mid abc -7d }
1350\end{align*}
1351.TEXE
1352
1353Find out if 87614 is divisible by 71:
1354
1355.TEXS
1356\begin{align*}
1357{ 8761 -7 \times 4 = 8733 }
1358\\
1359{ 873 -7 \times 3 = 852 }
1360\\
1361{ 85 -7 \times 2 = 71 }
1362\\
1363{ 71 \mid 71 \Rightarrow 71 \mid 87614 }
1364\end{align*}
1365.TEXE
1366
1367.HnS 2
1368.TAG "math-rev-div-alg-alt"
1369Alternative way of deriving recursive divisibility algorithms
1370.HnE
1371
1372Another way of proving the recursive divisibility theorems, instead of using a
1373two-way implication as I have done above, is to derive each rule from a
1374four-digit number
1375.I abcd .
1376Let me explain by deriving the rule of divisibility by 13, both for
1377.I n
1378= 4 and
1379.I n
1380= -9 (4 - 13).
1381
1382Say we have a four-digit number,
1383.I abcd ,
1384where
1385.I a
1386represents the number of thousands,
1387.I b
1388the number of hundreds,
1389.I c
1390the number of tens, and the number
1391.I d .
1392This number can be represented as
1393.I a "" 1000
1394+
1395.I b "" 100
1396+
1397.I c "" 10
1398+
1399.I d .
1400We then add and subtract different amounts of
1401.I as ,
1402.I bs ,
1403.I cs
1404and
1405.I ds
1406so that we can deduce the circumstances under which divisibility by 13 is
1407possible.
1408
1409.TEXS
1410\begin{align*}
1411{ 1000a + 100b + 10c + d }
1412\\
1413{ 1000a \hi{+ 300a} + 100b \hi{+ 30b} + 10c \hi{+ 3c} + d \hi{+ 12d}
1414  \hi{- 300a} \hi{- 30b} \hi{- 3c} \hi{- 12d}
1415}
1416\\
1417{ \hi{1300a} \hi{+ 130b} \hi{+ 13c} \hi{+ 13d}
1418  - 300a - 30b - 3c - 12d
1419}
1420\\
1421{  \hi{13 \left( 100a + 10b + c + d \right) }
1422   \hi{- 3 \left( 100a + 10b + c + 4d \right) }
1423}
1424\end{align*}
1425.TEXE
1426
1427We can now observe that the first term is divisible by 13 since 13 is clearly a
1428factor of that term. The second term has the factor 3, which is not divisible
1429by 13. Therefore, for the entire expression to be divisible by 13, the sum of
1430the terms inside the parenthesis must also be divisible by 13.
1431
1432.TEXS
1433\begin{align*}
1434{ 100a + 10b + c + 4d }
1435\\
1436{ \text{let } 100a + 10b + c = abc }
1437\\
1438{ \Rightarrow abc + 4d }
1439\end{align*}
1440.TEXE
1441
1442In other words,
1443.I abcd
1444is divisible by 13, if and only if,
1445.I abc
1446+
1447.I d "" 4
1448is divisible by 13, thus deriving the rule.
1449
1450To demonstrate its applicability when
1451.I n
1452= 4 - 13 = -9, we simply subtract and add 27 (3 \[mu] 9) instead of first adding
1453and subtracting 12 (3 \[mu] 4), as demonstrated above:
1454
1455.TEXS
1456\begin{align*}
1457{ 1000a + 100b + 10c + d }
1458\\
1459{ 1000a \hi{+ 300a} + 100b \hi{+ 30b} + 10c \hi{+ 3c} + d \hi{- 27d}
1460  \hi{- 300a} \hi{- 30b} \hi{- 3c} \hi{+ 27d}
1461}
1462\\
1463{ \hi{1300a} \hi{+ 130b} \hi{+ 13c} \hi{- 26d}
1464  - 300a - 30b - 3c + 27d
1465}
1466\\
1467{  \hi{13 \left( 100a + 10b + c - 2d \right) }
1468   \hi{- 3 \left( 100a + 10b + c - 9d \right) }
1469}
1470\end{align*}
1471.TEXE
1472
1473Once again, the first term is divisible by 13 since 13 is a factor of that
1474term. While the second term has the factor 3, which is not divisible by 13, the
1475sum of the terms inside the parentheses must be divisible by 13 for the entire
1476expression to be divisible by 13.
1477
1478.TEXS
1479\begin{align*}
1480{ 100a + 10b + c - 9d }
1481\\
1482{ \text{let } 100a + 10b + c = abc }
1483\\
1484{ \Rightarrow abc - 9d }
1485\end{align*}
1486.TEXE
1487
1488In other words,
1489.I abcd
1490is divisible by 13, if and only if,
1491.I abc
1492-
1493.I d "" 9
1494is divisible by 13, thus deriving the second rule.
1495
1496.HnS 1
1497.TAG "math-fractions"
1498Fractions
1499.HnE
1500
1501.HnS 2
1502.TAG "math-fractions-flip"
1503The fraction flip when dividing
1504.HnE
1505Many of you have probably been taught the trick of flipping the right fraction
1506in a division to instead use simpler multiplication. This is how it works:
1507
1508We start with the division:
1509
1510.TEXS
1511\[
1512{ 3 \over 2 } / { 4 \over 5 }
1513\]
1514.TEXE
1515
1516From there, we can reconstruct the two fractions as the dividend over
1517the divisor with a horizontal line, for simplicity's sake, like so:
1518
1519.TEXS
1520\[
1521\dfrac{3}{2} / \dfrac{4}{5}
1522= \dfrac{\dfrac{3}{2}}{\dfrac{4}{5}}
1523\]
1524.TEXE
1525
1526After that, the "trick" can begin. First, we multiply both the dividend and the
1527divisor with the inverse of the divisor. As long as we treat the dividend and
1528the divisor the same way, this is fine. However, keep PEMDAS in mind! If any of
1529the dividend or the divisor would have been an addition or subtraction, you
1530would have to multiply both terms by
1531.I x ,
1532either by
1533.I "x(a + b)"
1534or
1535.I "xa + xb" .
1536
1537.TEXS
1538\[
1539\dfrac{3}{2} / \dfrac{4}{5}
1540= \dfrac{\dfrac{3}{2}}{\dfrac{4}{5}}
1541= \dfrac{\dfrac{3}{2} \hi{\times \dfrac{5}{4}}}{\dfrac{4}{5} \hi{\times \dfrac{5}{4}}}
1542= \dfrac{\dfrac{3}{2} \times \dfrac{5}{4}}{\hi{\dfrac{4 \times 5}{5 \times 4}}}
1543= \dfrac{\dfrac{3}{2} \times \dfrac{5}{4}}{\hi{\dfrac{20}{20}}}
1544= \dfrac{\dfrac{3}{2} \times \dfrac{5}{4}}{\hi{1}}
1545= \dfrac{3}{2} \times \dfrac{5}{4}
1546\]
1547.TEXE
1548
1549As you can see, the right fraction has now "flipped", and not by magic, but
1550with logic and reason. So, as division by 1 is equal to the dividend, we can
1551then solve the expression, like so:
1552
1553.TEXS
1554\[
1555{ 3 \over 2 } \times { 5 \over 4 }
1556= {{ 3 \times 5 } \over { 2 \times 4 }}
1557= { 15 \over 18 }
1558\]
1559.TEXE
1560
1561As the final cherry on top, we can prove the procedure by dividing 1 by 2, as
1562we know this should result in one half.
1563
1564.TEXS
1565\[
15661 / 2
1567= \dfrac{1}{1} / \dfrac{2}{1}
1568= \dfrac{\dfrac{1}{1}}{\dfrac{2}{1}}
1569\]
1570.TEXE
1571
1572.TEXS
1573\[
1574\dfrac{1}{1} / \dfrac{2}{1}
1575= \dfrac{\dfrac{1}{1}}{\dfrac{2}{1}}
1576= \dfrac{\dfrac{1}{1} \hi{\times \dfrac{1}{2}}}{\dfrac{2}{1} \hi{\times \dfrac{1}{2}}}
1577= \dfrac{\dfrac{1}{1} \times \dfrac{1}{2}}{\hi{\dfrac{2 \times 1}{1 \times 2}}}
1578= \dfrac{\dfrac{1}{1} \times \dfrac{1}{2}}{\hi{\dfrac{2}{2}}}
1579= \dfrac{\dfrac{1}{1} \times \dfrac{1}{2}}{\hi{1}}
1580= \dfrac{1}{1} \times \dfrac{1}{2}
1581\]
1582.TEXE
1583
1584.TEXS
1585\[
1586{ 1 \over 1 } \times { 1 \over 2 }
1587= {{ 1 \times 1 } \over { 1 \times 2 }}
1588= { 1 \over 2 }
1589\]
1590.TEXE
1591
1592.DIVS theorem
1593.TEXS
1594\[
1595{a \over b} / {c \over d} = {a \over b} \times {d \over c}
1596\]
1597.TEXE
1598.DIVE