 So an important idea in cryptography is known as a congruence. To understand why these are important, let's talk about something that we might call the Goldilocks principle. When we try to solve an algebraic equation, we can usually rely on the intermediate value theorem to solve f of x equals c, find two values a and b, where f of a is less than c, which is less than f of b. The intermediate value theorem guarantees that there is a solution between x equals a and x equals b. Now there is some fine print here, which we won't bother reading, but rather we'll go straight to an application. So to solve x squared equals 12, we know that 3 squared is 9, 4 squared is 16, and so a solution exists between x equals 3 and x equals 4. Or if I want to solve 2 to power x equals 50, we know that 2 to power 5 is 32, 2 to power 6 is 64, and so a solution exists between x equals 5 and x equals 6. And if we want to gain more accuracy, lather, rinse, repeat. So a congruence equation is an equation that involves a, wait for it, congruence. So for example, we might have 5x plus 7 congruent to 27 mod 97. Or xq plus 4x plus 11 congruent to 5 mod 103. Or something like 17 to power x congruent to 3 mod 89. Or x to the fifth congruent to 41 mod 899. And now that fine print is relevant, so we have to ask ourselves, does the intermediate value theorem apply? And the answer is, no. And that's a problem, so we lead to the following, how can we solve these equations? And in general, we can't. And that's actually a good thing, because cryptography is based around problems that are hard to solve. Now, as with all generalizations, this one isn't strictly true, and there is one special case, a linear congruence. Now, to solve a linear equation, ax plus b equals c, we subtract b, and then we divide by a. Now, if I want to solve the linear congruence, ax plus b congruent to c, we subtract b, because we can still do subtraction mod n. What we can't do is we can't divide by a. So what do we do instead? Well, as always, let's try and see what happens. Let's try to solve if possible, 5x congruent to 1 mod 22. And something that's important to remember, guess and check always works, though it may take a while. So, because my solution has to be a number mod 22, I know the solution's going to be 1, 2, 3, 4, and so on. I know it's going to be a whole number, so let's try them out. If x is 1, 5 times 1 is congruent to 5 mod 22, but since we wanted 5x to be 1, this is not the solution. Now, we can also compute 5 times 2, 5 times 3, and 5 times 4. And since all of these numbers are less than 22, they're not going to change mod 22. But what happens when we multiply 5 by 5? Well, 5 times 5 is 25, but remember we're working mod 22, and the modulus is the least positive number equivalent to 0. And so this 25, I can think about that as 22 plus 3. And since we're working mod 22, the modulus is the least positive number equivalent to 0, so this 22 is like a 0. So we don't need to write it as long as we remind the reader that we are working mod 22. So 5 times 5 is 3. How about 5 times 6? Well, 5 times 6 is 30, which I can reduce by removing multiples of 22. And again, since we're working mod 22, 22 is like 0, and we can ignore it, leaving us with 8. 5 times 7 is 13, 5 times 8, 18, 5 times 9. So we could ignore this 22, and that would be 23, but we can also write 23 as 22 plus 1. And since we're working mod 22, both of these 22s can be ignored, leaving us with 1. And there's our solution. And it's useful to keep in mind, guess and check always works, though it may take a while. Another approach to solving this congruence is as follows. We might also consider all numbers that are congruent to 1 mod 22. So since 1 is congruent to 1 plus 22 mod 22, then 1 is congruent to 23. Since 1 is congruent to 1 plus 22 plus 22, then 1 is also congruent to 45, and so on. Now let's consider the equations 5x equals 1, 5x equals 23, 5x equals 45, and so on. And of these, we say that 5x equals 45 has integer solution x equal to 9. And it's useful to remember, integer solutions to an equation are solutions to a congruence. So I have an integer solution to 5x equals 45. So x equals 9 solves the congruence 5x congruent to 45, mod anything you like, but in this case we'll take mod 22. But since 45 is congruent to 1, that means that x equals 9 also solves the congruence 5x congruent to 1 mod 22.