Update the modulo patterns article to use new delimiters

Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
Danila Fedorin 2024-05-13 19:04:08 -07:00
parent 81eef51e88
commit 357a3bef09

View File

@ -76,15 +76,15 @@ If a number doesn't cleanly divide another (we're sticking to integers here),
what's left behind is the remainder. For instance, dividing 7 by 3 leaves us with a remainder 1.
On the other hand, if the remainder is zero, then that means that our dividend is divisible by the
divisor (what a mouthful). In mathematics, we typically use
\\(a|b\\) to say \\(a\\) divides \\(b\\), or, as we have seen above, that the remainder of dividing
\\(b\\) by \\(a\\) is zero.
\(a|b\) to say \(a\) divides \(b\), or, as we have seen above, that the remainder of dividing
\(b\) by \(a\) is zero.
Working with remainders actually comes up pretty frequently in discrete math. A well-known
example I'm aware of is the [RSA algorithm](https://en.wikipedia.org/wiki/RSA_(cryptosystem)),
which works with remainders resulting from dividing by a product of two large prime numbers.
But what's a good way to write, in numbers and symbols, the claim that "\\(a\\) divides \\(b\\)
with remainder \\(r\\)"? Well, we know that dividing yields a quotient (possibly zero) and a remainder
(also possibly zero). Let's call the quotient \\(q\\).
But what's a good way to write, in numbers and symbols, the claim that "\(a\) divides \(b\)
with remainder \(r\)"? Well, we know that dividing yields a quotient (possibly zero) and a remainder
(also possibly zero). Let's call the quotient \(q\).
{{< sidenote "right" "r-less-note" "Then, we know that when dividing \(b\) by \(a\) we have:" >}}
It's important to point out that for the equation in question to represent division
with quotient \(q\) and remainder \(r\), it must be that \(r\) is less than \(a\).
@ -111,7 +111,7 @@ larger than \(q\).
We only really care about the remainder here, not the quotient, since it's the remainder
that determines if something is divisible or not. From the form of the second equation, we can
deduce that \\(b-r\\) is divisible by \\(a\\) (it's literally equal to \\(a\\) times \\(q\\),
deduce that \(b-r\) is divisible by \(a\) (it's literally equal to \(a\) times \(q\),
so it must be divisible). Thus, we can write:
{{< latex >}}
@ -134,7 +134,7 @@ section](#adding-two-congruences) to see how it works):
a+c \equiv b+d\ (\text{mod}\ k).
{{< /latex >}}
Multiplying both sides by the same number (call it \\(n\\)) also works (once
Multiplying both sides by the same number (call it \(n\)) also works (once
again, you can find the proof in [this section below](#multiplying-both-sides-of-a-congruence)).
{{< latex >}}
@ -151,7 +151,7 @@ we have:
{{< /latex >}}
From this, we can deduce that multiplying by 10, when it comes to remainders from dividing by 3,
is the same as multiplying by 1. We can clearly see this by multiplying both sides by \\(n\\).
is the same as multiplying by 1. We can clearly see this by multiplying both sides by \(n\).
In our notation:
{{< latex >}}
@ -166,8 +166,8 @@ Multiplying by that number is _also_ equivalent to multiplying by 1!
{{< /latex >}}
We can put this to good use. Let's take a large number that's divisible by 3. This number
will be made of multiple digits, like \\(d_2d_1d_0\\). Note that I do __not__ mean multiplication
here, but specifically that each \\(d_i\\) is a number between 0 and 9 in a particular place
will be made of multiple digits, like \(d_2d_1d_0\). Note that I do __not__ mean multiplication
here, but specifically that each \(d_i\) is a number between 0 and 9 in a particular place
in the number -- it's a digit. Now, we can write:
{{< latex >}}
@ -178,11 +178,11 @@ in the number -- it's a digit. Now, we can write:
\end{aligned}
{{< /latex >}}
We have just found that \\(d_2+d_1+d_0 \\equiv 0\\ (\\text{mod}\ 3)\\), or that the sum of the digits
We have just found that \(d_2+d_1+d_0 \equiv 0\ (\text{mod}\ 3)\), or that the sum of the digits
is also divisible by 3. The logic we use works in the other direction, too: if the sum of the digits
is divisible, then so is the actual number.
There's only one property of the number 3 we used for this reasoning: that \\(10 \\equiv 1\\ (\\text{mod}\\ 3)\\). But it so happens that there's another number that has this property: 9. This means
There's only one property of the number 3 we used for this reasoning: that \(10 \equiv 1\ (\text{mod}\ 3)\). But it so happens that there's another number that has this property: 9. This means
that to check if a number is divisible by _nine_, we can also check if the sum of the digits is
divisible by 9. Try it on 18, 27, 81, and 198.
@ -210,7 +210,7 @@ does this work, and why does it always loop around? Why don't we ever spiral far
from the center?
First, let's take a closer look at our sequence of multiples. Suppose we're working with multiples
of some number \\(n\\). Let's write \\(a_i\\) for the \\(i\\)th multiple. Then, we end up with:
of some number \(n\). Let's write \(a_i\) for the \(i\)th multiple. Then, we end up with:
{{< latex >}}
\begin{aligned}
@ -224,9 +224,9 @@ of some number \\(n\\). Let's write \\(a_i\\) for the \\(i\\)th multiple. Then,
{{< /latex >}}
This is actually called an [arithmetic sequence](https://mathworld.wolfram.com/ArithmeticProgression.html);
for each multiple, the number increases by \\(n\\).
for each multiple, the number increases by \(n\).
Here's a first seemingly trivial point: at some time, the remainder of \\(a_i\\) will repeat.
Here's a first seemingly trivial point: at some time, the remainder of \(a_i\) will repeat.
There are only so many remainders when dividing by nine: specifically, the only possible remainders
are the numbers 0 through 8. We can invoke the [pigeonhole principle](https://en.wikipedia.org/wiki/Pigeonhole_principle) and say that after 9 multiples, we will have to have looped. Another way
of seeing this is as follows:
@ -240,7 +240,7 @@ of seeing this is as follows:
{{< /latex >}}
The 10th multiple is equivalent to n, and will thus have the same remainder. The looping may
happen earlier: the simplest case is if we pick 9 as our \\(n\\), in which case the remainder
happen earlier: the simplest case is if we pick 9 as our \(n\), in which case the remainder
will always be 0.
Repeating remainders alone do not guarantee that we will return to the center. The repeating sequence 1,2,3,4
@ -280,15 +280,15 @@ Okay, so we want to avoid cycles with lengths divisible by four. What does it me
\end{aligned}
{{< /latex >}}
If we could divide both sides by \\(k\\), we could go one more step:
If we could divide both sides by \(k\), we could go one more step:
{{< latex >}}
n \equiv 0\ (\text{mod}\ 9) \\
{{< /latex >}}
That is, \\(n\\) would be divisible by 9! This would contradict our choice of \\(n\\) to be
between 2 and 8. What went wrong? Turns out, it's that last step: we can't always divide by \\(k\\).
Some values of \\(k\\) are special, and it's only _those_ values that can serve as cycle lengths
That is, \(n\) would be divisible by 9! This would contradict our choice of \(n\) to be
between 2 and 8. What went wrong? Turns out, it's that last step: we can't always divide by \(k\).
Some values of \(k\) are special, and it's only _those_ values that can serve as cycle lengths
without causing a contradiction. So, what are they?
They're values that have a common factor with 9 (an incomplete explanation is in
@ -314,8 +314,8 @@ we want to avoid those numbers that would allow for cycles of length 4 (or of a
If we didn't avoid them, we might run into infinite loops, where our pencil might end up moving
further and further from the center.
Actually, let's revisit that. When we were playing with paths of length \\(k\\) while dividing by 9,
we noted that the only _possible_ values of \\(k\\) are those that share a common factor with 9,
Actually, let's revisit that. When we were playing with paths of length \(k\) while dividing by 9,
we noted that the only _possible_ values of \(k\) are those that share a common factor with 9,
specifically 3, 6 and 9. But that's not quite as strong as it could be: try as you might, but
you will not find a cycle of length 6 when dividing by 9. The same is true if we pick 6 instead of 9,
and try to find a cycle of length 4. Even though 4 _does_ have a common factor with 6, and thus
@ -326,7 +326,7 @@ So what is it that _really_ determines if there can be cycles or not?
Let's do some more playing around. What are the actual cycle lengths when we divide by 9?
For all but two numbers, the cycle lengths are 9. The two special numbers are 6 and 3, and they end up
with a cycle length of 3. From this, we can say that the cycle length seems to depend on whether or
not our \\(n\\) has any common factors with the divisor.
not our \(n\) has any common factors with the divisor.
Let's explore this some more with a different divisor, say 12. We fill find that 8 has a cycle length
of 3, 7 has a cycle length of 12, 9 has a cycle length of 4. What's
@ -340,50 +340,50 @@ for the length of a cycle:
k = \frac{d}{\text{gcd}(d,n)}
{{< /latex >}}
Where \\(d\\) is our divisor, which has been 9 until just recently, and \\(\\text{gcd}(d,n)\\)
is the greatest common factor of \\(d\\) and \\(n\\). This equation is in agreement
with our experiment for \\(d = 9\\), too. Why might this be? Recall that sequences with
period \\(k\\) imply the following congruence:
Where \(d\) is our divisor, which has been 9 until just recently, and \(\text{gcd}(d,n)\)
is the greatest common factor of \(d\) and \(n\). This equation is in agreement
with our experiment for \(d = 9\), too. Why might this be? Recall that sequences with
period \(k\) imply the following congruence:
{{< latex >}}
kn \equiv 0\ (\text{mod}\ d)
{{< /latex >}}
Here I've replaced 9 with \\(d\\), since we're trying to make it work for _any_ divisor, not just 9.
Now, suppose the greatest common divisor of \\(n\\) and \\(d\\) is some number \\(f\\). Then,
since this number divides \\(n\\) and \\(d\\), we can write \\(n=fm\\) for some \\(m\\), and
\\(d=fg\\) for some \\(g\\). We can rewrite our congruence as follows:
Here I've replaced 9 with \(d\), since we're trying to make it work for _any_ divisor, not just 9.
Now, suppose the greatest common divisor of \(n\) and \(d\) is some number \(f\). Then,
since this number divides \(n\) and \(d\), we can write \(n=fm\) for some \(m\), and
\(d=fg\) for some \(g\). We can rewrite our congruence as follows:
{{< latex >}}
kfm \equiv 0\ (\text{mod}\ fg)
{{< /latex >}}
We can simplify this a little bit. Recall that what this congruence really means is that the
difference of \\(kfm\\) and \\(0\\), which is just \\(kfm\\), is divisible by \\(fg\\):
difference of \(kfm\) and \(0\), which is just \(kfm\), is divisible by \(fg\):
{{< latex >}}
fg|kfm
{{< /latex >}}
But if \\(fg\\) divides \\(kfm\\), it must be that \\(g\\) divides \\(km\\)! This, in turn, means
But if \(fg\) divides \(kfm\), it must be that \(g\) divides \(km\)! This, in turn, means
we can write:
{{< latex >}}
g|km
{{< /latex >}}
Can we distill this statement even further? It turns out that we can. Remember that we got \\(g\\)
and \\(m\\) by dividing \\(d\\) and \\(n\\) by their greatest common factor, \\(f\\). This, in
turn, means that \\(g\\) and \\(m\\) have no more common factors that aren't equal to 1 (see
[this section below](#numbers-divided-by-their-textgcd-have-no-common-factors)). From this, in turn, we can deduce that \\(m\\) is not
relevant to \\(g\\) dividing \\(km\\), and we get:
Can we distill this statement even further? It turns out that we can. Remember that we got \(g\)
and \(m\) by dividing \(d\) and \(n\) by their greatest common factor, \(f\). This, in
turn, means that \(g\) and \(m\) have no more common factors that aren't equal to 1 (see
[this section below](#numbers-divided-by-their-textgcd-have-no-common-factors)). From this, in turn, we can deduce that \(m\) is not
relevant to \(g\) dividing \(km\), and we get:
{{< latex >}}
g|k
{{< /latex >}}
That is, we get that \\(k\\) must be divisible by \\(g\\). Recall that we got \\(g\\) by dividing
\\(d\\) by \\(f\\), which is our largest common factor -- aka \\(\\text{gcd}(d,n)\\). We can thus
That is, we get that \(k\) must be divisible by \(g\). Recall that we got \(g\) by dividing
\(d\) by \(f\), which is our largest common factor -- aka \(\text{gcd}(d,n)\). We can thus
write:
{{< latex >}}
@ -391,26 +391,26 @@ write:
{{< /latex >}}
Let's stop and appreciate this result. We have found a condition that is required for a sequnce
of remainders from dividing by \\(d\\) (which was 9 in the original problem) to repeat after \\(k\\)
numbers. Furthermore, all of our steps can be performed in reverse, which means that if a \\(k\\)
of remainders from dividing by \(d\) (which was 9 in the original problem) to repeat after \(k\)
numbers. Furthermore, all of our steps can be performed in reverse, which means that if a \(k\)
matches this conditon, we can work backwards and determine that a sequence of numbers has
to repeat after \\(k\\) steps.
to repeat after \(k\) steps.
Multiple \\(k\\)s will match this condition, and that's not surprising. If a sequence repeats after 5 steps,
Multiple \(k\)s will match this condition, and that's not surprising. If a sequence repeats after 5 steps,
it also repeats after 10, 15, and so on. We're interested in the first time our sequences repeat after
taking any steps, which means we have to pick the smallest possible non-zero value of \\(k\\). The smallest
number divisible by \\(d/\\text{gcd}(d,n)\\) is \\(d/\\text{gcd}(d,n)\\) itself. We thus confirm
taking any steps, which means we have to pick the smallest possible non-zero value of \(k\). The smallest
number divisible by \(d/\text{gcd}(d,n)\) is \(d/\text{gcd}(d,n)\) itself. We thus confirm
our hypothesis:
{{< latex >}}
k = \frac{d}{\text{gcd}(d,n)}
{{< /latex >}}
Lastly, recall that our patterns would spiral away from the center whenever a \\(k\\) is a multiple of 4. Now that we know what
\\(k\\) is, we can restate this as "\\(d/\\text{gcd}(d,n)\\) is divisible by 4". But if we pick
\\(n=d-1\\), the greatest common factor has to be \\(1\\) (see [this section below](#divisors-of-n-and-n-1)), so we can even further simplify this "\\(d\\) is divisible by 4".
Lastly, recall that our patterns would spiral away from the center whenever a \(k\) is a multiple of 4. Now that we know what
\(k\) is, we can restate this as "\(d/\text{gcd}(d,n)\) is divisible by 4". But if we pick
\(n=d-1\), the greatest common factor has to be \(1\) (see [this section below](#divisors-of-n-and-n-1)), so we can even further simplify this "\(d\) is divisible by 4".
Thus, we can state simply that any divisor divisible by 4 is off-limits, as it will induce loops.
For example, pick \\(d=4\\). Running our algorithm
For example, pick \(d=4\). Running our algorithm
{{< sidenote "right" "constructive-note" "for \(n=d-1=3\)," >}}
Did you catch that? From our work above, we didn't just find a condition that would prevent spirals;
we also found the precise number that would result in a spiral if this condition were violated!
@ -426,7 +426,7 @@ spiral:
{{< figure src="pattern_3_4.svg" caption="Spiral generated by the number 3 with divisor 4." class="tiny" alt="Spiral generated by the number 3 by summing digits." >}}
Let's try again. Pick \\(d=8\\); then, for \\(n=d-1=7\\), we also get a spiral:
Let's try again. Pick \(d=8\); then, for \(n=d-1=7\), we also get a spiral:
{{< figure src="pattern_7_8.svg" caption="Spiral generated by the number 7 with divisor 8." class="tiny" alt="Spiral generated by the number 7 by summing digits." >}}
@ -455,17 +455,17 @@ Finally, base-30:
### Generalizing to Arbitrary Numbers of Directions
What if we didn't turn 90 degrees each time? What, if, instead, we turned 120 degrees (so that
turning 3 times, not 4, would leave you facing the same direction you started)? We can pretty easily
do that, too. Let's call this number of turns \\(c\\). Up until now, we had \\(c=4\\).
do that, too. Let's call this number of turns \(c\). Up until now, we had \(c=4\).
First, let's update our condition. Before, we had "\\(d\\) cannot be divisible by 4". Now,
we aren't constraining ourselves to only 4, but rather using a generic variable \\(c\\).
We then end up with "\\(d\\) cannot be divisible by \\(c\\)". For instance, suppose we kept
First, let's update our condition. Before, we had "\(d\) cannot be divisible by 4". Now,
we aren't constraining ourselves to only 4, but rather using a generic variable \(c\).
We then end up with "\(d\) cannot be divisible by \(c\)". For instance, suppose we kept
our divisor as 9 for the time being, but started turning 3 times instead of 4. This
violates our divisibility condtion, and we once again end up with a spiral:
{{< figure src="pattern_8_9_t3.svg" caption="Pattern generated by the number 8 in base 10 while turning 3 times." class="tiny" alt="Pattern generated by the number 3 by summing digits and turning 120 degrees." >}}
If, on the other hand, we pick \\(d=8\\) and \\(c=3\\), we get patterns for all numbers just like we hoped.
If, on the other hand, we pick \(d=8\) and \(c=3\), we get patterns for all numbers just like we hoped.
Here's one such pattern:
{{< figure src="pattern_7_8_t3.svg" caption="Pattern generated by the number 7 in base 9 while turning 3 times." class="tiny" alt="Pattern generated by the number 7 by summing digits in base 9 and turning 120 degrees." >}}
@ -529,7 +529,7 @@ up facing up again. If we turned 480 degrees (that is, two turns of 240 degrees
360 can be safely ignored, since it puts us where we started; only the 120 degrees that remain
are needed to figure out our final bearing. In short, the final direction we're facing is
the remainder from dividing by 360. We already know how to formulate this using modular arithmetic:
if we turn \\(t\\) degrees \\(k\\) times, and end up at final bearing (remainder) \\(b\\), this
if we turn \(t\) degrees \(k\) times, and end up at final bearing (remainder) \(b\), this
is captured by:
{{< latex >}}
@ -544,18 +544,18 @@ Of course, if we end up facing the same way we started, we get the familiar equi
Even though the variables in this equivalence mean different things now than they did last
time we saw it, the mathematical properties remain the same. For instance, we can say that
after \\(360/\\text{gcd}(360, t)\\) turns, we'll end up facing the way that we started.
after \(360/\text{gcd}(360, t)\) turns, we'll end up facing the way that we started.
So far, so good. What I don't like about this, though, is that we have all of these
numbers of degrees all over our equations: 72 degrees, 144 degrees, and so forth. However,
something like 73 degrees (if there are five possible directions) is just not a valid bearing,
and nor is 71. We have so many possible degrees (360 of them, to be exact), but we're only
using a handful! That's wasteful. Instead, observe that for \\(c\\) possible turns,
the smallest possible turn angle is \\(360/c\\). Let's call this angle \\(\\theta\\) (theta).
Now, notice that we always turn in multiples of \\(\\theta\\): a single turn moves us \\(\\theta\\)
degrees, two turns move us \\(2\\theta\\) degrees, and so on. If we define \\(r\\) to be
using a handful! That's wasteful. Instead, observe that for \(c\) possible turns,
the smallest possible turn angle is \(360/c\). Let's call this angle \(\theta\) (theta).
Now, notice that we always turn in multiples of \(\theta\): a single turn moves us \(\theta\)
degrees, two turns move us \(2\theta\) degrees, and so on. If we define \(r\) to be
the number of turns that we find ourselves rotated by after a single cycle,
we have \\(t=r\\theta\\), and our turning equation can be written as:
we have \(t=r\theta\), and our turning equation can be written as:
{{< latex >}}
kr\theta \equiv 0\ (\text{mod}\ c\theta)
@ -570,58 +570,58 @@ Now, once again, recall that the above equivalence is just notation for the foll
\end{aligned}
{{< /latex >}}
And finally, observing that \\(kr=kr-0\\), we have:
And finally, observing that \(kr=kr-0\), we have:
{{< latex >}}
kr \equiv 0\ (\text{mod}\ c)
{{< /latex >}}
This equivalence says the same thing as our earlier one; however, instead of being in terms
of degrees, it's in terms of the number of turns \\(c\\) and the turns-per-cycle \\(r\\).
Now, recall once again that the smallest number of steps \\(k>0\\) for which this equivalence holds is
\\(k = c/\\text{gcd}(c,r)\\).
of degrees, it's in terms of the number of turns \(c\) and the turns-per-cycle \(r\).
Now, recall once again that the smallest number of steps \(k>0\) for which this equivalence holds is
\(k = c/\text{gcd}(c,r)\).
We're close now: we have a sequence of \\(k\\) steps that will lead us back to the beginning.
What's left is to show that these \\(k\\) steps are evenly distributed throughout our circle,
We're close now: we have a sequence of \(k\) steps that will lead us back to the beginning.
What's left is to show that these \(k\) steps are evenly distributed throughout our circle,
which is the key property that makes it possible for us to make a polygon out of them (and
thus end up back where we started).
To show this, say that we have a largest common divisor \\(f=\\text{gcd}(c,r)\\), and that \\(c=fe\\) and \\(r=fs\\). We can once again "divide through" by \\(f\\), and
To show this, say that we have a largest common divisor \(f=\text{gcd}(c,r)\), and that \(c=fe\) and \(r=fs\). We can once again "divide through" by \(f\), and
get:
{{< latex >}}
ks \equiv 0\ (\text{mod}\ e)
{{< /latex >}}
Now, we know that \\(\\text{gcd}(e,s)=1\\) ([see this section below](#numbers-divided-by-their-textgcd-have-no-common-factors)), and thus:
Now, we know that \(\text{gcd}(e,s)=1\) ([see this section below](#numbers-divided-by-their-textgcd-have-no-common-factors)), and thus:
{{< latex >}}
k = e/\text{gcd}(e,s) = e
{{< /latex >}}
That is, our cycle will repeat after \\(e\\) remainders. But wait, we've only got \\(e\\) possible
remainders: the numbers \\(0\\) through \\(e-1\\)! Thus, for a cycle to repeat after \\(e\\) remainders,
all possible remainders must occur. For a concrete example, take \\(e=5\\); our remainders will
be the set \\(\\{0,1,2,3,4\\}\\). Now, let's "multiply back through"
by \\(f\\):
That is, our cycle will repeat after \(e\) remainders. But wait, we've only got \(e\) possible
remainders: the numbers \(0\) through \(e-1\)! Thus, for a cycle to repeat after \(e\) remainders,
all possible remainders must occur. For a concrete example, take \(e=5\); our remainders will
be the set \(\{0,1,2,3,4\}\). Now, let's "multiply back through"
by \(f\):
{{< latex >}}
kfs \equiv 0\ (\text{mod}\ fe)
{{< /latex >}}
We still have \\(e\\) possible remainders, but this time they are multiplied by \\(f\\).
For example, taking \\(e\\) to once again be equal to \\(5\\), we have the set of possible remainders
\\(\\{0, f, 2f, 3f, 4f\\}\\). The important bit is that these remainders are all evenly spaced, and
that space between them is \\(f=\\text{gcd}(c,r)\\).
We still have \(e\) possible remainders, but this time they are multiplied by \(f\).
For example, taking \(e\) to once again be equal to \(5\), we have the set of possible remainders
\(\{0, f, 2f, 3f, 4f\}\). The important bit is that these remainders are all evenly spaced, and
that space between them is \(f=\text{gcd}(c,r)\).
Let's recap: we have confirmed that for \\(c\\) possible turns (4 in our original formulation),
and \\(r\\) turns at a time, we will always loop after \\(k=c/\\text{gcd}(c,r)\\) steps,
evenly spaced out at \\(\\text{gcd}(c,r)\\) turns. No specific properties from \\(c\\) or \\(r\\)
Let's recap: we have confirmed that for \(c\) possible turns (4 in our original formulation),
and \(r\) turns at a time, we will always loop after \(k=c/\text{gcd}(c,r)\) steps,
evenly spaced out at \(\text{gcd}(c,r)\) turns. No specific properties from \(c\) or \(r\)
are needed for this to work. Finally, recall from the previous
section that \\(r\\) is zero (and thus, our pattern breaks down) whenever the divisor \\(d\\) (9 in our original formulation) is itself
divisible by \\(c\\). And so, __as long as we pick a system with \\(c\\) possible directions
and divisor \\(d\\), we will always loop back and create a pattern as long as \\(c\\nmid d\\) (\\(c\\)
does not divide \\(d\\))__.
section that \(r\) is zero (and thus, our pattern breaks down) whenever the divisor \(d\) (9 in our original formulation) is itself
divisible by \(c\). And so, __as long as we pick a system with \(c\) possible directions
and divisor \(d\), we will always loop back and create a pattern as long as \(c\nmid d\) (\(c\)
does not divide \(d\))__.
Let's try it out! There's a few pictures below. When reading the captions, keep in mind that the _base_
is one more than the _divisor_ (we started with numbers in the usual base 10, but divided by 9).
@ -652,12 +652,12 @@ up a lot of space (and were interrupting the flow of the explanation). They are
### Referenced Proofs
#### Adding Two Congruences
__Claim__: If for some numbers \\(a\\), \\(b\\), \\(c\\), \\(d\\), and \\(k\\), we have
\\(a \\equiv b\\ (\\text{mod}\\ k)\\) and \\(c \\equiv d\\ (\\text{mod}\\ k)\\), then
it's also true that \\(a+c \\equiv b+d\\ (\\text{mod}\\ k)\\).
__Claim__: If for some numbers \(a\), \(b\), \(c\), \(d\), and \(k\), we have
\(a \equiv b\ (\text{mod}\ k)\) and \(c \equiv d\ (\text{mod}\ k)\), then
it's also true that \(a+c \equiv b+d\ (\text{mod}\ k)\).
__Proof__: By definition, we have \\(k|(a-b)\\) and \\(k|(c-d)\\). This, in turn, means
that for some \\(i\\) and \\(j\\), \\(a-b=ik\\) and \\(c-d=jk\\). Add both sides to get:
__Proof__: By definition, we have \(k|(a-b)\) and \(k|(c-d)\). This, in turn, means
that for some \(i\) and \(j\), \(a-b=ik\) and \(c-d=jk\). Add both sides to get:
{{< latex >}}
\begin{aligned}
& (a-b)+(c-d) = ik+jk \\
@ -666,63 +666,63 @@ that for some \\(i\\) and \\(j\\), \\(a-b=ik\\) and \\(c-d=jk\\). Add both sides
\Rightarrow\ & a+c \equiv b+d\ (\text{mod}\ k) \\
\end{aligned}
{{< /latex >}}
\\(\\blacksquare\\)
\(\blacksquare\)
#### Multiplying Both Sides of a Congruence
__Claim__: If for some numbers \\(a\\), \\(b\\), \\(n\\) and \\(k\\), we have
\\(a \\equiv b\\ (\\text{mod}\\ k)\\) then we also have that \\(an \\equiv bn\\ (\\text{mod}\\ k)\\).
__Claim__: If for some numbers \(a\), \(b\), \(n\) and \(k\), we have
\(a \equiv b\ (\text{mod}\ k)\) then we also have that \(an \equiv bn\ (\text{mod}\ k)\).
__Proof__: By definition, we have \\(k|(a-b)\\). Since multiplying \\(a-b\\) but \\(n\\) cannot
make it _not_ divisible by \\(k\\), we also have \\(k|\\left[n(a-b)\\right]\\). Distributing
\\(n\\), we have \\(k|(na-nb)\\). By definition, this means \\(na\\equiv nb\\ (\\text{mod}\\ k)\\).
__Proof__: By definition, we have \(k|(a-b)\). Since multiplying \(a-b\) but \(n\) cannot
make it _not_ divisible by \(k\), we also have \(k|\left[n(a-b)\right]\). Distributing
\(n\), we have \(k|(na-nb)\). By definition, this means \(na\equiv nb\ (\text{mod}\ k)\).
\\(\\blacksquare\\)
\(\blacksquare\)
#### Invertible Numbers \\(\\text{mod}\\ d\\) Share no Factors with \\(d\\)
__Claim__: A number \\(k\\) is only invertible (can be divided by) in \\(\\text{mod}\\ d\\) if \\(k\\)
and \\(d\\) share no common factors (except 1).
__Claim__: A number \(k\) is only invertible (can be divided by) in \(\text{mod}\ d\) if \(k\)
and \(d\) share no common factors (except 1).
__Proof__: Write \\(\\text{gcd}(k,d)\\) for the greatest common factor divisor of \\(k\\) and \\(d\\).
Another important fact (not proven here, but see something [like this](https://sharmaeklavya2.github.io/theoremdep/nodes/number-theory/gcd/gcd-is-min-lincomb.html)), is that if \\(\\text{gcd}(k,d) = r\\),
then the smallest possible number that can be made by adding and subtracting \\(k\\)s and \\(d\\)s
is \\(r\\). That is, for some \\(i\\) and \\(j\\), the smallest possible positive value of \\(ik + jd\\) is \\(r\\).
__Proof__: Write \(\text{gcd}(k,d)\) for the greatest common factor divisor of \(k\) and \(d\).
Another important fact (not proven here, but see something [like this](https://sharmaeklavya2.github.io/theoremdep/nodes/number-theory/gcd/gcd-is-min-lincomb.html)), is that if \(\text{gcd}(k,d) = r\),
then the smallest possible number that can be made by adding and subtracting \(k\)s and \(d\)s
is \(r\). That is, for some \(i\) and \(j\), the smallest possible positive value of \(ik + jd\) is \(r\).
Now, note that \\(d \\equiv 0\\ (\\text{mod}\\ d)\\). Multiplying both sides by \\(j\\), get
\\(jd\\equiv 0\\ (\\text{mod}\\ d)\\). This, in turn, means that the smallest possible
value of \\(ik+jd \\equiv ik\\) is \\(r\\). If \\(r\\) is bigger than 1 (i.e., if
\\(k\\) and \\(d\\) have common factors), then we can't pick \\(i\\) such that \\(ik\\equiv1\\),
since we know that \\(r>1\\) is the least possible value we can make. There is therefore no
multiplicative inverse to \\(k\\). Alternatively worded, we cannot divide by \\(k\\).
Now, note that \(d \equiv 0\ (\text{mod}\ d)\). Multiplying both sides by \(j\), get
\(jd\equiv 0\ (\text{mod}\ d)\). This, in turn, means that the smallest possible
value of \(ik+jd \equiv ik\) is \(r\). If \(r\) is bigger than 1 (i.e., if
\(k\) and \(d\) have common factors), then we can't pick \(i\) such that \(ik\equiv1\),
since we know that \(r>1\) is the least possible value we can make. There is therefore no
multiplicative inverse to \(k\). Alternatively worded, we cannot divide by \(k\).
\\(\\blacksquare\\)
\(\blacksquare\)
#### Numbers Divided by Their \\(\\text{gcd}\\) Have No Common Factors
__Claim__: For any two numbers \\(a\\) and \\(b\\) and their largest common factor \\(f\\),
if \\(a=fc\\) and \\(b=fd\\), then \\(c\\) and \\(d\\) have no common factors other than 1 (i.e.,
\\(\\text{gcd}(c,d)=1\\)).
__Claim__: For any two numbers \(a\) and \(b\) and their largest common factor \(f\),
if \(a=fc\) and \(b=fd\), then \(c\) and \(d\) have no common factors other than 1 (i.e.,
\(\text{gcd}(c,d)=1\)).
__Proof__: Suppose that \\(c\\) and \\(d\\) do have sommon factor, \\(e\\neq1\\). In that case, we have
\\(c=ei\\) and \\(d=ej\\) for some \\(i\\) and \\(j\\). Then, we have \\(a=fei\\), and \\(b=fej\\).
From this, it's clear that both \\(a\\) and \\(b\\) are divisible by \\(fe\\). Since \\(e\\)
is greater than \\(1\\), \\(fe\\) is greater than \\(f\\). But our assumptions state that
\\(f\\) is the greatest common divisor of \\(a\\) and \\(b\\)! We have arrived at a contradiction.
__Proof__: Suppose that \(c\) and \(d\) do have sommon factor, \(e\neq1\). In that case, we have
\(c=ei\) and \(d=ej\) for some \(i\) and \(j\). Then, we have \(a=fei\), and \(b=fej\).
From this, it's clear that both \(a\) and \(b\) are divisible by \(fe\). Since \(e\)
is greater than \(1\), \(fe\) is greater than \(f\). But our assumptions state that
\(f\) is the greatest common divisor of \(a\) and \(b\)! We have arrived at a contradiction.
Thus, \\(c\\) and \\(d\\) cannot have a common factor other than 1.
Thus, \(c\) and \(d\) cannot have a common factor other than 1.
\\(\\blacksquare\\)
\(\blacksquare\)
#### Divisors of \\(n\\) and \\(n-1\\).
__Claim__: For any \\(n\\), \\(\\text{gcd}(n,n-1)=1\\). That is, \\(n\\) and \\(n-1\\) share
__Claim__: For any \(n\), \(\text{gcd}(n,n-1)=1\). That is, \(n\) and \(n-1\) share
no common divisors.
__Proof__: Suppose some number \\(f\\) divides both \\(n\\) and \\(n-1\\).
In that case, we can write \\(n=af\\), and \\((n-1)=bf\\) for some \\(a\\) and \\(b\\).
__Proof__: Suppose some number \(f\) divides both \(n\) and \(n-1\).
In that case, we can write \(n=af\), and \((n-1)=bf\) for some \(a\) and \(b\).
Subtracting one equation from the other:
{{< latex >}}
1 = (a-b)f
{{< /latex >}}
But this means that 1 is divisible by \\(f\\)! That's only possible if \\(f=1\\). Thus, the only
number that divides \\(n\\) and \\(n-1\\) is 1; that's our greatest common factor.
But this means that 1 is divisible by \(f\)! That's only possible if \(f=1\). Thus, the only
number that divides \(n\) and \(n-1\) is 1; that's our greatest common factor.
\\(\\blacksquare\\)
\(\blacksquare\)