Fun With Modular Arithmetic

The modulo (or "modulus" or "mod") is the remainder after dividing one number by another. Example: mod 9 equals 1. Because /9 = 11 with a remainder of 1. Another example: 14 mod 12 equals 2. Because 14/12 = 1 with a remainder of 2. hour time uses modulo 12 (14 o'clock becomes 2 o'clock). Modulo, often abbreviated “mod,” is a mathematical operation. It’s like a division problem, except that the answer is the remainder of an integer division operation, rather than a decimal result. To illustrate: Decimal division: 25 ? 4 = Integer division: 25 ? 4 = 6 with a remainder of 1.

Before you can begin to understand statisticsyou need to understand mean, median, and mode. Without these three methods of calculation, it would be impossible to interpret much of the data we use in daily life. Each is used to find the statistical midpoint in a group of numbers, but they all do so differently. When people talk about statistical averagesthey are referring to the mean. To calculate the mean, simply add all of your numbers together. Next, divide the sum by however many numbers you added.

The result is your mean or average score. For example, let's say you have four test scores: 15, 18, 22, **what is mod in mathematical terms** To find the average, you would first add all four scores together, then divide the sum by four.

The resulting mean is Written out, it looks something like this:. If you were to round up to the nearest whole number, the average would be The median is the middle value in a data set. To calculate it, place all of your numbers in increasing order. If you have an odd number of integers, the next step is to find the middle number on your list. In this example, the middle or median number is If you have an even number of data points, calculating the median requires another step or two. First, find the two middle integers in your list.

Add them together, then divide by two. The result is the median number. In what is the statistical study of all populations example, the two middle numbers are 8 and Written out, the calculation would look like this:.

In this instance, the median is In statistics, the mode in a list of numbers refers to the integers that occur most frequently. Unlike the median and mean, the mode is about the frequency of occurrence. There can be more than one mode or no mode at all; it all depends on the data set itself. For example, let's say you have the following list of numbers:.

In this case, the mode is 15 because it is the integer that appears most often. However, if there were one fewer 15 in your list, then you would have four modes: 3, 15, 17, and Occasionally in statistics, you'll also be asked for the range in a set of numbers. The range is simply the smallest number subtracted from the largest number in your set. For example, let's use the following numbers:. To calculate the range, you would subtract 3 from 44, giving you a range of Written out, the equation looks like this:.

Once you've mastered the basics of mean, median, and mode, you can begin to learn about more statistical concepts. A good next step is studying probabilitythe chance of an event happening. Share Flipboard Email. Deb Russell. Math Expert. Deb Russell is a school principal and teacher with over 25 years of experience teaching mathematics at all levels.

Updated January 23, Cite this Article Format. Russell, Deb. Calculating the Mean, Median, and Mode. Calculating the Mean Absolute Deviation. What Are the First and Third Quartiles? Profile of Women in the United States in Math Glossary: Mathematics Terms and Definitions.

ThoughtCo uses cookies to provide you with a great user experience. By using ThoughtCo, you accept our.

Enter the Modulo

Modular arithmetic, sometimes referred to as modulus arithmetic or clock arithmetic, in its most elementary form, arithmetic done with a count that resets itself to zero every time a certain whole number N greater than one, known as the modulus (mod), has been reached. ab ? 1(mod m). (5) By de?nition (1) this means that ab ? 1 = k · m for some integer k. As before, there are may be many solutions to this equation but we choose as a representative the smallest positive solution and say that the inverse a?1 is given by a?1 = b (MOD m). Ex 3. 3 has inverse 7 modulo 10 since 3·7 = 21 shows thatFile Size: 57KB. Mod [ m, n] gives the remainder on division of m by n. Mod [ m, n, d] uses an offset d.

Shortly after discovering whole numbers 1, 2, 3, 4, 5… we realized they fall into two groups:. This is huge — it lets us explore math at a deeper level and find relationships between types of numbers, not specific ones.

For example, we can make rules like this:. These rules are general — they work at the property level. What about the number 3? How about this:. Weird, but workable. Cool, huh? Where will the hour hand be in 7 hours? So it must be 2. We do this reasoning intuitively, and in math terms:. So, the clock will end up 1 hour ahead, at Well, they change to the same amount on the clock!

We can just add 5 to the 2 remainder that both have, and they advance the same. For all congruent numbers 2 and 14 , adding and subtracting has the same result. But who cares? We ignore the overflow anyway. See the above link for more rigorous proofs — these are my intuitive pencil lines. You have a flight arriving at 3pm.

What time will it land? Suppose you have people who bought movie tickets, with a confirmation number. You want to divide them into 2 groups. What do you do? Need 3 groups? Divide by 3 and take the remainder aka mod 3. In programming, taking the modulo is how you can fit items into a hash table: if your table has N entries, convert the item key to a number, do mod N, and put the item in that bucket perhaps keeping a linked list there.

As your hash table grows in size, you can recompute the modulo for the keys. I use the modulo in real life. We have 4 people playing a game and need to pick someone to go first.

Play the mod N mini-game! Give people numbers 0, 1, 2, and 3. Add them up and divide by 4 — whoever gets the remainder exactly goes first. Oh, you need task C1 which runs 1x per hour, but not the same time as task C? The neat thing is that the hits can overlap independently. What can you deduce quickly? So we can use modulo to figure out whether numbers are consistent, without knowing what they are! A contradication, good fellows!

The modular properties apply to integers, so what we can say is that b cannot be an integer. Playing with numbers has very important uses in cryptography. Geeks love to use technical words in regular contexts. Happy math! Learn Right, Not Rote. Home Articles Popular Calculus. Feedback Contact About Newsletter. Odd, Even and Threeven Shortly after discovering whole numbers 1, 2, 3, 4, 5… we realized they fall into two groups: Even: divisible by 2 0, 2, 4, Where will the big hand be in 25 hours?

Uses Of Modular Arithmetic Now the fun part — why is modular arithmetic useful? This is a bit more involved than a plain modulo operator, but the principle is the same. Putting Items In Random Groups Suppose you have people who bought movie tickets, with a confirmation number. Picking A Random Item I use the modulo in real life. Know its limits: it applies to integers. Cryptography Playing with numbers has very important uses in cryptography.

Plain English Geeks love to use technical words in regular contexts. In general, I see a few general use cases: Range reducer: take an input, mod N, and you have a number from 0 to N Group assigner: take an input, mod N, and you have it tagged as a group from 0 to N Join k Monthly Readers Enjoy the article?

There's plenty more to help you build a lasting, intuitive understanding of math. Join the newsletter for bonus content and the latest updates.

Join for Free Lessons.

Thanks a lot, u r an inspiration

Yeah but that was last year