# Simple Encryption

Interesting

Is this right? I thought the point of using modular arithmetic is to avoid floating point overflow, so you have to do it for each multiplication:

(CASCADE is in the "Iteration, composition" library.)

I don’t know anything about modular arithmetic so it sounds like I need to learn about it.

Yeah, if you want to do modern cryptography you have to understand MOD. Luckily, it's way easier than a lot of the math that's been flying around here recently. :~)

Mainly what you have to understand is the linearity:

(a+b) (mod p) = [(a mod p) + (b mod p)] (mod p)

and the same for ×. So mathematically, doing the modding before and after the computation gives the same answer. But computationally, you don't get the same answer because of floating point overflow.

Honestly, I like to think of 'mod' like this:

It's probably not how it actually works when you start digging deeper, but every time I've had to use it this is what it's been like.

Yeah, that's basically right, except for negative n1.

is the built-in version...

I was talking to insert_user_name, not you!