morbet.blogg.se

What is a mod
What is a mod













what is a mod what is a mod

The modulo operation (abbreviated “mod”, or “%” in many programming languages) is the remainder when dividing. Perhaps not as immediately useful as even/odd, but it’s there: we can make rules like “threeven x threeven = threeven” and so on.īut it’s getting crazy. A number like “4” is 1 away from being threeven (remainder 1), while the number 5 is two away (remainder 2).īeing “threeven” is just another property of a number. You’ll notice a few things: there’s two types of throdd. “Throdd” means you are not divisible by 3 (1, 2, 4, 5, 7, 8…).“Threeven” means a number is divisbile by 3 (0, 3, 6, 9…).(Intuitively, I have a chemical analogy that “evenness” is a molecule some numbers have, and cannot be removed by multiplication.)īut even/odd is a very specific property: division by 2. These rules are general - they work at the property level. For example, we can make rules like this:

what is a mod

This is huge - it lets us explore math at a deeper level and find relationships between types of numbers, not specific ones. Why’s this distinction important? It’s the beginning of abstraction - we’re noticing the properties of a number (like being even or odd) and not just the number itself (“37”). Shortly after discovering whole numbers (1, 2, 3, 4, 5…) we realized they fall into two groups: There’s a nice article on modular arithmetic that inspired this post. Instead of hitting you in the face with formulas, let’s explore an idea we’ve been subtly exposed to for years. I hadn’t given it much thought, but realized the modulo is extremely powerful: it should be in our mental toolbox next to addition and multiplication. A reader recently suggested I write about modular arithmetic (aka “taking the remainder”).















What is a mod