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.EQ
1001 ~|~ a ~iff~ a ~\[mo]~ "Z\h'-.83m'Z"
101.EN
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.EQ
137lpile {
138{ 1000a ~+~ 100b ~+~ 10c ~+~ 2n }
139above
140{ lineup 2 left ( 500a ~+~ 50b ~+~ 5c ~+~ n right ) }
141}
142.EN
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.EQ
1492 ~|~ abcd ~iff~ 2 ~|~ d
150.EN
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.EQ
1613 ~|~ abcd ~iff~ 3 ~|~ left ( a ~+~ b ~+~ c ~+~ d right )
162.EN
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.EQ
192lpile {
193{ 1000a ~+~ 100b ~+~ 10c ~+~ d }
194above
195{ lineup left ( 999a ~+~ 99b ~+~ 9c right ) ~+~ left ( a ~+~ b ~+~ c ~+~ d right ) }
196above
197{ lineup 3 left ( 333a ~+~ 33b ~+~ 3c right ) ~+~ left ( a ~+~ b ~+~ c ~+~ d right ) }
198}
199.EN
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.EQ
2143 ~|~ abcd ~iff~ 3 ~|~ left ( a ~+~ b ~+~ c ~+~ d right )
215.EN
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.EQ
2314 ~|~ abcd ~iff~ 4 ~|~ cd
232.EN
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.EQ
257lpile {
258{ 1000a ~+~ 100b ~+~ 10c ~+~ d }
259above
260{ lineup 4 left ( 250a ~+~ 25b ) ~+~ left ( 10c ~+~ d right ) }
261}
262.EN
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.EQ
2704 ~|~ abcd ~iff~ 4 ~|~ cd
271.EN
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.EQ
2825 ~|~ abcd ~iff~ 5 ~|~ d
283.EN
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.EQ
308lpile {
309{ 1000a ~+~ 100b ~+~ 10c ~+~ d }
310above
311{ lineup 5 left ( 500a ~+~ 50b ~+~ 5c right ) ~+~ d }
312}
313.EN
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.EQ
3235 ~|~ abcd ~iff~ 5 ~|~ d
324.EN
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.EQ
3386 ~|~ abcd ~iff~ 3 ~|~ left ( a ~+~ b ~+~ c ~+~ d right ) ~\[AN]~ 2~|~d
339.EN
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.EQ
366lpile {
367{ 7 ~|~ 3423 ~? }
368above
369{ 342 ~-~ 3 ~times~ 2 ~=~ 336 }
370above
371{ 33 ~-~ 6 ~times~ 2 ~=~ 21 }
372above
373{ 7 ~|~ 21 ~implies~ 7 ~|~ 3423 }
374}
375.EN
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.EQ
412{ a ~-~ 2b ~=~ 7k }
413.EN
414
415Multiply the whole equation by 10, and add one extra
416.I b :
417
418.EQ
419lpile {
420{ hi{10}a ~-~ hi{20}b ~=~ hi{70}k }
421above
422{ 10a ~-~ 20b hi{~+~ b} ~=~ 70k hi{~+~ b} }
423above
424{ 10a ~-~ hi{19b} ~=~ 70k ~+~ b }
425}
426.EN
427
428Now add
429.I b "" 20
430to each side of the equation, and try to factor out 7:
431
432.EQ
433lpile {
434{ 10a ~-~ 19b hi{~+~ 20b} ~=~ 70k ~+~ b hi{~+~ 20b} }
435above
436{ 10a hi{~+~ b} ~=~ 70k hi{~+~ 21b} }
437above
438{ 10a ~+~ b ~=~ hi{7 left ( 10k ~+~ 3b right )} }
439}
440.EN
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.EQ
470{ 10a ~+~ b ~=~ 7k }
471.EN
472
473Subtract
474.I b "" 21
475from the whole equation, and factorize:
476
477.EQ
478lpile {
479{ 10a ~+~ b hi{~-~ 21b} ~=~ 7k hi{~-~ 21b} }
480above
481{ 10a hi{~-~ 20b} ~=~ 7k ~-~ 21b }
482above
483{ hi{10 left ( a ~-~ 2b right ) } ~=~ hi{7 left ( k ~-~ 3b right ) } }
484}
485.EN
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.EQ
4977 ~|~ ab ~iff~ 7 ~|~ a ~-~ 2b
498.EN
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.EQ
5138 ~|~ abcd ~iff~ 8 ~|~ bcd
514.EN
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.EQ
539lpile {
540{ 1000a ~+~ 100b ~+~ 10c ~+~ d }
541above
542{ lineup 8 left ( 125a right ) ~+~ left ( 100b ~+~ 10c ~+~ d right ) }
543}
544.EN
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.EQ
5528 ~|~ abcd ~iff~ 8 ~|~ bcd
553.EN
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.EQ
5669 ~|~ abcd ~iff~ 9 ~|~ left ( a ~+~ b ~+~ c ~+~ d right )
567.EN
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.EQ
593lpile {
594{ 1000a ~+~ 100b ~+~ 10c ~+~ d }
595above
596{ lineup left ( 999a ~+~ 99b ~+~ 9c right ) ~+~ left ( a ~+~ b ~+~ c ~+~ d right ) }
597above
598{ lineup 9 left ( 111a ~+~ 11b ~+~ 1c right ) ~+~ left ( a ~+~ b ~+~ c ~+~ d right ) }
599}
600.EN
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.EQ
6159 ~|~ abcd ~iff~ 9 ~|~ left ( a ~+~ b ~+~ c ~+~ d right )
616.EN
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.EQ
63210 ~|~ abcd ~iff~ 10 ~|~ d
633.EN
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.EQ
658lpile {
659{ 1000a ~+~ 100b ~+~ 10c ~+~ d }
660above
661{ lineup 10 left ( 100a ~+~ 10b ~+~ c right ) ~+~ d }
662}
663.EN
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.EQ
67310 ~|~ abcd ~iff~ 10 ~|~ d
674.EN
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.EQ
685lpile {
686{ 11 ~|~ 190905 ~? }
687above
688{ 1 ~-~ 9 ~+~ 0 ~-~ 9 ~+~ 0 ~-~ 5 ~=~ -22 }
689above
690{ 11 ~|~ -22 ~implies~ 11 ~|~ 190905 }
691}
692.EN
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.EQ
717lpile {
718{ 1000a ~+~ 100b ~+~ 10c ~+~ d }
719above
720{ hi{ a left ( 1000 right ) } ~+~
721  hi{ b left ( 100 right ) } ~+~
722  hi{ c left ( 10 right ) } ~+~ d }
723above
724{ a left ( hi{ 1001 ~-~ 1 } right ) ~+~
725  b left ( hi{ 99 ~+~ 1 } right ) ~+~
726  c left ( hi{ 11 ~-~ 1 } right ) ~+~ d }
727above
728{ hi{ 1001a ~-~ a } ~+~
729  hi{ 99b ~+~ b } ~+~
730  hi{ 11c ~-~ c} ~+~ d }
731above
732{ 1001a hi{ ~+~ 99b ~+~ 11c ~-~ a ~+~ b} ~-~ c ~+~ d }
733}
734.EN
735
736Now we factorize the expression, like so:
737
738.EQ
739hi{ 11 left ( 91a ~+~ 9b ~+~ c right ) } ~-~ a ~+~ b ~-~ c ~+~ d
740.EN
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.EQ
748lpile {
749{ 11 ~|~ abcd ~iff~ 11 ~|~ -a ~+~ b ~-~ c ~+~ d }
750above
751{ 11 ~|~ abcd ~iff~ 11 ~|~ a ~-~ b ~+~ c ~-~ d }
752}
753.EN
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.EQ
772lpile {
773{ 13 ~|~ 76752 ~? }
774above
775{ 7675 ~+~ 2 ~times~ 4 ~=~ 7683 }
776above
777{ 768 ~+~ 3 ~times~ 4 ~=~ 780 }
778above
779{ 78 ~+~ 0 ~times~ 4 ~=~ 78 }
780above
781{ 7 ~+~ 8 ~times~ 4 ~=~ 39 }
782above
783{ 13 ~|~ 39 ~implies~ 13 ~|~ 76752 }
784}
785.EN
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.EQ
822{ a ~+~ 4b ~=~ 13k }
823.EN
824
825Multiply the whole equation by 10, and add one extra
826.I b :
827
828.EQ
829lpile {
830{ hi{10}a ~+~ hi{40}b ~=~ hi{130}k }
831above
832{ 10a ~+~ 40b hi{~+~ b} ~=~ 130k hi{~+~ b} }
833above
834{ 10a ~+~ hi{41b} ~=~ 130k ~+~ b }
835}
836.EN
837
838Now subtract
839.I b "" 40
840from each side of the equation, and try to factor out 13:
841
842.EQ
843lpile {
844{ 10a ~+~ 41b hi{~-~ 40b} ~=~ 130k ~+~ b hi{~-~ 40b} }
845above
846{ 10a hi{~+~ b} ~=~ 130k hi{~-~ 39b} }
847above
848{ 10a ~+~ b ~=~ hi{13 left ( 10k ~-~ 3b right )} }
849}
850.EN
851
852We can now see that the right side of the equation is divisible by 13, and our
853left side says
854.I a "" 10
855+
856.I b .
857Neat, we now know that the two-digit number
858.I ab
859is divisible by 13. Now we must show that
860.B B
861implies
862.B A .
863That is, if
864.I a
865+
866.I b "" 4
867is divisible by 13, then
868.I a "" 10
869+
870.I b
871is divisible by 13. Let's prove
872.B B .
873
874Just as for
875.B A ,
876we know that 13 must be a factor of the expression. We can
877now create another equation:
878
879.EQ
880{ 10a ~+~ b ~=~ 13k }
881.EN
882
883Add
884.I b "" 39
885to both sides of the equation, and factorize:
886
887.EQ
888lpile {
889{ 10a ~+~ b hi{~+~ 39b} ~=~ 13k hi{~+~ 39b} }
890above
891{ 10a hi{~+~ 40b} ~=~ 13k ~+~ 39b }
892above
893{ hi{10 left ( a ~+~ 4b right ) } ~=~ hi{13 left ( k ~+~ 3b right ) } }
894}
895.EN
896
897We can now see that the right side of the equation is divisible by 13, and on
898our left hand, 10 is not divisible by 13, so the expression inside the
899parenthesis must be. But isn't that expression
900.I a
901+
902.I b ? 4
903We now have the proof for the theorem and can conclude that, indeed,
904
905.DIVS theorem
906.EQ
90713 ~|~ ab ~iff~ 13 ~|~ a ~+~ 4b
908.EN
909.DIVE
910
911We have shown that the procedure above will hold for all cases.
912
913.HnS 2
914.TAG "math-div-theorems-17"
915Divisibility by 17
916.HnE
917Just like the theorem of divisibility by 7 and 13,
918the theorem of
919.I "divisibility by 17" ,
920is recursive.
921The theorem states that if the difference between last digit multiplied by
9225 and the remaining digits in a number is divisible by 17, the whole number is
923divisible by 17. I'll show you the procedure with an example below:
924
925.EQ
926lpile {
927{ 17 ~|~ 206091 ~? }
928above
929{ 20609 ~-~ 1 ~times~ 5 ~=~ 20604 }
930above
931{ 2060 ~-~ 4 ~times~ 5 ~=~ 2040 }
932above
933{ 204 ~-~ 0 ~times~ 5 ~=~ 204 }
934above
935{ 20 ~-~ 4 ~times~ 5 ~=~ 0 }
936above
937{ 17 ~|~ 0 ~implies~ 17 ~|~ 206091 }
938}
939.EN
940
941If you are not satisfied with 0 being the numerator, here is another example:
942
943.EQ
944lpile {
945{ 17 ~|~ 2057 ~? }
946above
947{ 205 ~-~ 7 ~times~ 5 ~=~ 170 }
948above
949{ 17 ~-~ 0 ~times~ 5 ~=~ 17 }
950above
951{ 17 ~|~ 17 ~implies~ 17 ~|~ 2057 }
952}
953.EN
954
955Neat! So how and why does it work? For simplicity's sake, we use a two-digit
956number
957.I ab ,
958represented as
959.I a "" 10
960+
961.I b .
962The theorem says that if
963.B A ) (
96417 |
965.I a
966-
967.I b "" 5
968then
969.B B ) (
97017 |
971.I a "" 10
972+
973.I b .
974Let's prove it!
975
976In order to prove the theorem, we must prove both
977.B A
978and
979.B B .
980So let's start with
981.B A .
982If we have
983.I a
984-
985.I b , 5
986and it's divisible by 17, we know that 17 must be a factor of the
987expression. We can now create an equation.
988
989.EQ
990{ a ~-~ 5b ~=~ 17k }
991.EN
992
993Multiply the whole equation by 10, and add one extra
994.I b :
995
996.EQ
997lpile {
998{ hi{10}a ~-~ hi{50}b ~=~ hi{170}k }
999above
1000{ 10a ~-~ 50b hi{~+~ b} ~=~ 170k hi{~+~ b} }
1001above
1002{ 10a ~-~ hi{49b} ~=~ 170k ~+~ b }
1003}
1004.EN
1005
1006Now add
1007.I b "" 50
1008to each side of the equation, and try to factor out 17:
1009
1010.EQ
1011lpile {
1012{ 10a ~-~ 49b hi{~+~ 50b} ~=~ 170k ~+~ b hi{~+~ 50b} }
1013above
1014{ 10a hi{~+~ b} ~=~ 170k hi{~+~ 51b} }
1015above
1016{ 10a ~+~ b ~=~ hi{17 left ( 10k ~+~ 3b right )} }
1017}
1018.EN
1019
1020We can now see that the right side of the equation is divisible by 17, and our
1021left side says
1022.I a "" 10
1023+
1024.I b .
1025Neat, we now know that the two-digit number
1026.I ab
1027is divisible by 17. Now we must show that
1028.B B
1029implies
1030.B A .
1031That is, if
1032.I a
1033-
1034.I b "" 5
1035is divisible by 17, then
1036.I a "" 10
1037+
1038.I b
1039is divisible by 17. Let's prove
1040.B B .
1041
1042Just as for
1043.B A ,
1044we know that 17 must be a factor of the expression. We can
1045now create another equation:
1046
1047.EQ
1048{ 10a ~+~ b ~=~ 17k }
1049.EN
1050
1051Subtract
1052.I b "" 51
1053from both sides of the equation, and factorize:
1054
1055.EQ
1056lpile {
1057{ 10a ~+~ b hi{~-~ 51b} ~=~ 17k hi{~-~ 51b} }
1058above
1059{ 10a hi{~-~ 50b} ~=~ 17k ~+~ 51b }
1060above
1061{ hi{10 left ( a ~-~ 5b right ) } ~=~ hi{17 left ( k ~-~ 3b right ) } }
1062}
1063.EN
1064
1065We can now see that the right side of the equation is divisible by 17, and on
1066our left hand, 10 is not divisible by 17, so the expression inside the
1067parenthesis must be. But isn't that expression
1068.I a
1069-
1070.I b ? 5
1071We now have the proof for the theorem and can conclude that, indeed,
1072
1073.DIVS theorem
1074.EQ
107517 ~|~ ab ~iff~ 17 ~|~ a ~-~ 5b
1076.EN
1077.DIVE
1078
1079We have shown that the procedure above will hold for all cases.
1080
1081.HnS 1
1082.TAG "math-rec-div-alg"
1083Recursive divisibility algorithms
1084.HnE
1085As you might have noticed, there are some divisibility rules that are quite
1086similar. The rules for divisibility by 7, 13, and 17 are all based on a
1087recursive algorithm in which the last digit is multiplied by a certain number
1088and then either added to or subtracted from the number represented by the
1089remaining digits. Similar to this
1090
1091.EQ
1092abcd -> abc ~+~ d times n
1093.EN
1094
1095where
1096.I n
1097represents the number that is multiplied by the last digit
1098.I d .
1099In the theorems proven above, the rules for divisibility by 7, 13 and 17 could
1100be summarized like so:
1101
1102.EQ
1103lpile {
1104{7 ~|~ abcd ~iff~ 7 ~|~  abc -2 times d}
1105above
1106{13 ~|~ abcd ~iff~ 13 ~|~  abc +4 times d}
1107above
1108{17 ~|~ abcd ~iff~ 17 ~|~  abc -5 times d}
1109}
1110.EN
1111
1112Except for
1113.I n
1114being different in each algorithm, they are all the same. They could, in fact,
1115be summarized even shorter by only stating the divisor and the number
1116.I n
1117in this way:
1118
1119.CDS
1120.COS
11217: -2
112213: +4
112317: -5
1124.COE
1125.CDE
1126
1127Divisibility by 11 could also be tested in this manner by having
1128.I n
1129= -1. However, the
1130.URL #math-div-theorems-11 rule
1131of alternating subtraction and addition between the digits in a number is much
1132more effective than using the recursive algorithm for testing divisibility by
113311.
1134
1135There are, in fact, multiple divisibility rules that can be constructed using
1136the recursive algorithm by only changing the number
1137.I n .
1138I have written a short Python script that finds all recursive divisibility
1139rules along with their corresponding
1140.I n .
1141However, I haven’t ensured that all the rules found actually work in all cases;
1142there could be false positives. They would need to be proven algebraically
1143first. The ones I have proven to be correct, including 11, are:
1144
1145.CDS
1146.COS
11477: -2
114811: -1
114913: +4
115017: -5
1151.COE
1152.CDE
1153
1154Before you think that the pattern is connected to prime numbers, try the
1155algorithm with divisibility by 27 using
1156.I n
1157= -8. The next working number after 27 is, in fact, 29, and all prime numbers
1158are included. There are in fact some other interesting patterns...
1159
1160.HnS 2
1161.TAG "math-rev-div-alg-script"
1162Python script for finding recursive divisibility algorithms
1163.HnE
1164
1165If you would like to discover and prove the remaining ones, as I have done for
11667, 13, and 17, you can try using this Python script:
1167
1168.CDS
1169.COS
1170#!/usr/bin/env python3
1171
1172# find all recursive divisibility algorithms from 1 through 99
1173for div in range(1, 100):
1174
1175	# test all recursive additions from 2 up to the div
1176	for n in range(2, div):
1177
1178		# create a large number with div as a known factor
1179		num = div * 123456789123456
1180
1181		# perform recursive calculations while number is divisible by the div
1182		while num % div == 0 and num > div:
1183			# keep track of the previous number
1184			prev = num
1185
1186			# perform recursive calculation (abcd -> abc + d*n)
1187			num = int(str(num)[:-1]) + int(str(num)[-1]) * n
1188
1189			# break on infinite loop
1190			if (prev == num or prev == div):
1191				break
1192
1193		# make last check to see if the number is divisible by the div
1194		if (num % div == 0):
1195
1196			# use the smallest (disregarding if it's negative or positive)
1197			# number in the recursive calculations.
1198			# this means that there is always to ways to perform the recursive
1199			# calculations, either by addition or by subtraction
1200			#
1201			# ex: 13: abcd -> abc -9d or abc +4d
1202			# in this example 4 < 9, so 4 is the smallest
1203			if (div - n < n):
1204				n -= div
1205			print("{:d}: {:+d}".format(div, n))
1206			break
1207.COE
1208.CDE
1209
1210When running the script, you might discover some interesting patterns from 11
1211and up:
1212
1213.CDS
1214.COS
1215        1 --->    11: -1     |-
1216        3 |       13: +4               <---
1217   +10  7 |       17: -5         <--      |
1218        9 |       19: +2     |+    |      | +3
1219        1 --->    21: -2     |-    | -3   |
1220        3 |       23: +7           |   <---
1221   +10  7 |       27: -8         <--      |
1222        9 |       29: +3     |+    |      | +3
1223        1 --->    31: -3     |-    | -3   |
1224        3 |       33: +10          |   <---
1225   +10  7 |       37: -11        <--      |
1226        9 |       39: +4     |+    |      | +3
1227        1 --->    41: -4     |-    | -3   |
1228        3 |       43: +13          |   <---
1229   +10  7 |       47: -14        <--      |
1230        9 |       49: +5     |+    |      | +3
1231        1 --->    51: -5     |-    | -3   |
1232        3 |       53: +16          |   <---
1233   +10  7 |       57: -17        <--      |
1234        9 |       59: +6     |+    |      | +3
1235        1 --->    61: -6     |-    | -3   |
1236        3 |       63: +19          |   <---
1237   +10  7 |       67: -20        <--      |
1238        9 |       69: +7     |+    |      | +3
1239        1 --->    71: -7     |-    | -3   |
1240        3 |       73: +22          |   <---
1241   +10  7 |       77: -23        <--      |
1242        9 |       79: +8     |+    |      | +3
1243        1 --->    81: -8     |-    | -3   |
1244        3 |       83: +25          |   <---
1245   +10  7 |       87: -26        <--      |
1246        9 |       89: +9     |+    |      | +3
1247        1 --->    91: -9     |-    | -3   |
1248        3 |       93: +28          |   <---
1249        7 |       97: -29        <--
1250        9 |       99: +10    |+
1251.COE
1252.CDE
1253
1254Even if the script won't output 3 and 9, they do follow the same pattern.
1255And the same could technically be said about 1. So, the pattern actually starts
1256at 1 and continues into infinity. And as all prime numbers end with either 1,
12573, 7 or 9, except for 2 and 5, all prime numbers are included. This is a known
1258sequence:
1259.URL https://oeis.org/A333448 https://oeis.org/A333448
1260
1261.HnS 2
1262.TAG "math-rev-div-alg-find"
1263Finding all divisibility algorithms for primes
1264.HnE
1265Based on the output from the script and the knowledge about all primes being
1266included, except for 2 and 5, we could construct a short list of everything we
1267need to find out if a number is divisible by any prime number.
1268
1269What we need:
1270.OLS
1271.LI
1272The divisibility rule for the prime number 2: is the last digit an even number?
1273
1274.EQ
12752 ~|~ abcd ~iff~ 2 ~|~ d
1276.EN
1277
1278.LI
1279The divisibility rule for the prime number 5: is the last digit a 5 or a 0?
1280
1281.EQ
12825 ~|~ abcd ~iff~ 5 ~|~ d
1283.EN
1284
1285.LI
1286A general rule for any number with the last digit being 1, 3, 7 or 9, including
1287the rest of all prime numbers:
1288
1289.EQ
1290n ~|~ abcd ~iff~ n ~|~ abc ~+~ D(n) times d
1291.EN
1292
1293.LI
1294A way to calculate D(n):
1295
1296.EQ
1297D(n) ~\[==]~ left {
1298matrix {
1299lcol {
1300~9a + 1,
1301above
1302~3a + 1,
1303above
1304~7a + 5,
1305above ~a + 1,
1306}
1307lcol {
1308roman{if} ~n = 10a+1
1309above
1310roman{if} ~n = 10a+3
1311above
1312roman{if} ~n = 10a+7
1313above
1314roman{if} ~n = 10a+9
1315}
1316}
1317.EN
1318
1319If we want a small number,
1320.I D(n) ,
1321to add or subtract:
1322
1323.EQ
1324D sub {s}(n) ~\[==]~ left {
1325matrix {
1326lcol {
1327D(n) - n,
1328above
1329D(n),
1330}
1331lcol {
1332roman{if} ~n - D(n) < D(n)
1333above
1334roman{otherwise}
1335}
1336}
1337.EN
1338.OLE
1339
1340Example, get the divisibility algorithm for the prime number 71:
1341
1342.EQ
1343lpile{
1344{ D(71) = 9 times 7 + 1 = 64 }
1345above
1346{ D sub {s}(n) = 64 - 71 = -7 }
1347above
1348{ implies~ 71~|~abcd ~iff~ 71~|~abc -7d }
1349}
1350.EN
1351
1352Find out if 87614 is divisible by 71:
1353
1354.EQ
1355lpile{
1356{ 8761 -7 times 4 = 8733 }
1357above
1358{ 873 -7 times 3 = 852 }
1359above
1360{ 85 -7 times 2 = 71 }
1361above
1362{ 71 ~|~ 71 ~implies~ 71 ~|~ 87614 }
1363}
1364.EN
1365
1366.HnS 2
1367.TAG "math-rev-div-alg-alt"
1368Alternative way of deriving recursive divisibility algorithms
1369.HnE
1370
1371Another way of proving the recursive divisibility theorems, instead of using a
1372two-way implication as I have done above, is to derive each rule from a
1373four-digit number
1374.I abcd .
1375Let me explain by deriving the rule of divisibility by 13, both for
1376.I n
1377= 4 and
1378.I n
1379= -9 (4 - 13).
1380
1381Say we have a four-digit number,
1382.I abcd ,
1383where
1384.I a
1385represents the number of thousands,
1386.I b
1387the number of hundreds,
1388.I c
1389the number of tens, and the number
1390.I d .
1391This number can be represented as
1392.I a "" 1000
1393+
1394.I b "" 100
1395+
1396.I c "" 10
1397+
1398.I d .
1399We then add and subtract different amounts of
1400.I as ,
1401.I bs ,
1402.I cs
1403and
1404.I ds
1405so that we can deduce the circumstances under which divisibility by 13 is
1406possible.
1407
1408.EQ
1409lpile {
1410{ 1000a ~+~ 100b ~+~ 10c ~+~ d }
1411above
1412{ 1000a hi{~+~ 300a} ~+~ 100b hi{~+~ 30b} ~+~ 10c hi{~+~ 3c} ~+~ d hi{~+~ 12d}
1413  hi{~-~ 300a} hi{~-~ 30b} hi{~-~ 3c} hi{~-~ 12d}
1414}
1415above
1416{ hi{1300a} hi{~+~ 130b} hi{~+~ 13c} hi{~+~ 13d}
1417  ~-~ 300a ~-~ 30b ~-~ 3c ~-~ 12d
1418}
1419above
1420{  hi{13 left ( 100a ~+~ 10b ~+~ c ~+~ d right ) }
1421   hi{~-~ 3 left ( 100a ~+~ 10b ~+~ c ~+~ 4d right ) }
1422}
1423}
1424.EN
1425
1426We can now observe that the first term is divisible by 13 since 13 is clearly a
1427factor of that term. The second term has the factor 3, which is not divisible
1428by 13. Therefore, for the entire expression to be divisible by 13, the sum of
1429the terms inside the parenthesis must also be divisible by 13.
1430
1431.EQ
1432lpile {
1433{ 100a ~+~ 10b ~+~ c ~+~ 4d }
1434above
1435{ roman{let}~ 100a ~+~ 10b ~+~ c = abc }
1436above
1437{ implies~ abc ~+~ 4d }
1438}
1439.EN
1440
1441In other words,
1442.I abcd
1443is divisible by 13, if and only if,
1444.I abc
1445+
1446.I d "" 4
1447is divisible by 13, thus deriving the rule.
1448
1449To demonstrate its applicability when
1450.I n
1451= 4 - 13 = -9, we simply subtract and add 27 (3 \[mu] 9) instead of first adding
1452and subtracting 12 (3 \[mu] 4), as demonstrated above:
1453
1454.EQ
1455lpile {
1456{ 1000a ~+~ 100b ~+~ 10c ~+~ d }
1457above
1458{ 1000a hi{~+~ 300a} ~+~ 100b hi{~+~ 30b} ~+~ 10c hi{~+~ 3c} ~+~ d hi{~-~ 27d}
1459  hi{~-~ 300a} hi{~-~ 30b} hi{~-~ 3c} hi{~+~ 27d}
1460}
1461above
1462{ hi{1300a} hi{~+~ 130b} hi{~+~ 13c} hi{~-~ 26d}
1463  ~-~ 300a ~-~ 30b ~-~ 3c ~+~ 27d
1464}
1465above
1466{  hi{13 left ( 100a ~+~ 10b ~+~ c ~-~ 2d right ) }
1467   hi{~-~ 3 left ( 100a ~+~ 10b ~+~ c ~-~ 9d right ) }
1468}
1469}
1470.EN
1471
1472Once again, the first term is divisible by 13 since 13 is a factor of that
1473term. While the second term has the factor 3, which is not divisible by 13, the
1474sum of the terms inside the parentheses must be divisible by 13 for the entire
1475expression to be divisible by 13.
1476
1477.EQ
1478lpile {
1479{ 100a ~+~ 10b ~+~ c ~-~ 9d }
1480above
1481{ roman{let}~ 100a ~+~ 10b ~+~ c = abc }
1482above
1483{ implies~ abc ~-~ 9d }
1484}
1485.EN
1486
1487In other words,
1488.I abcd
1489is divisible by 13, if and only if,
1490.I abc
1491-
1492.I d "" 9
1493is divisible by 13, thus deriving the second rule.
1494
1495.HnS 1
1496.TAG "math-fractions"
1497Fractions
1498.HnE
1499
1500.HnS 2
1501.TAG "math-fractions-flip"
1502The fraction flip when dividing
1503.HnE
1504Many of you have probably been taught the trick of flipping the right fraction
1505in a division to instead use simpler multiplication. This is how it works:
1506
1507We start with the division:
1508
1509.EQ
1510{ 3 over 2 } / { 4 over 5 }
1511.EN
1512
1513From there, we can reconstruct the two fractions as the dividend over
1514the divisor with a horizontal line, for simplicity's sake, like so:
1515
1516.EQ
1517{ 3 over 2 } / { 4 over 5 }
1518~=~ {{ 3 over 2 } over { 4 over 5 }}
1519.EN
1520
1521After that, the "trick" can begin. First, we multiply both the dividend and the
1522divisor with the inverse of the divisor. As long as we treat the dividend and
1523the divisor the same way, this is fine. However, keep PEMDAS in mind! If any of
1524the dividend or the divisor would have been an addition or subtraction, you
1525would have to multiply both terms by
1526.I x ,
1527either by
1528.I "x(a + b)"
1529or
1530.I "xa + xb" .
1531
1532.EQ
1533{ 3 over 2 } / { 4 over 5 }
1534~=~ {{ 3 over 2 } over { 4 over 5 }}
1535~=~ {{{ 3 over 2 } hi {~times~ 5 over 4 }} over {{ 4 over 5 } hi {~times~ 5 over 4 }}}
1536~=~ {{{ 3 over 2 } ~times~ { 5 over 4 }} over hi{{ 4 ~times~ 5 } over { 5 ~times~ 4 }}}
1537~=~ {{{ 3 over 2 } ~times~ { 5 over 4 }} over hi{20 over 20}}
1538~=~ {{{ 3 over 2 } ~times~ { 5 over 4 }} over hi{1}}
1539~=~ { 3 over 2 } ~times~ { 5 over 4 }
1540.EN
1541
1542As you can see, the right fraction has now "flipped", and not by magic, but
1543with logic and reason. So, as division by 1 is equal to the dividend, we can
1544then solve the expression, like so:
1545
1546.EQ
1547{ 3 over 2 } ~times~ { 5 over 4 }
1548~=~ {{ 3 ~times~ 5 } over { 2 ~times~ 4 }}
1549~=~ { 15 over 18 }
1550.EN
1551
1552As the final cherry on top, we can prove the procedure by dividing 1 by 2, as
1553we know this should result in one half.
1554
1555.EQ
1556{ 1 / 2 }
1557~=~ { 1 over 1 } / { 2 over 1 }
1558~=~ { 1 over 1 } over { 2 over 1 }
1559.EN
1560
1561.EQ
1562{ 1 over 1 } / { 2 over 1 }
1563~=~ { 1 over 1 } over { 2 over 1 }
1564~=~ {{{ 1 over 1 } hi {~times~ 1 over 2 }} over {{ 2 over 1 } hi {~times~ 1 over 2 }}}
1565~=~ {{{ 1 over 1 } ~times~ { 1 over 2 }} over hi{{ 2 ~times~ 1 } over { 1 ~times~ 2 }}}
1566~=~ {{{ 1 over 1 } ~times~ { 1 over 2 }} over hi{2 over 2}}
1567~=~ {{{ 1 over 1 } ~times~ { 1 over 2 }} over hi{1}}
1568~=~ { 1 over 1 } ~times~ { 1 over 2 }
1569.EN
1570
1571.EQ
1572{ 1 over 1 } ~times~ { 1 over 2 }
1573~=~ {{ 1 ~times~ 1 } over { 1 ~times~ 2 }}
1574~=~ { 1 over 2 }
1575.EN
1576
1577.DIVS theorem
1578.EQ
1579a over b / c over d ~=~ a over b ~times~ d over c
1580.EN
1581.DIVE