# Modular Arithmetic in the Garden

Sowing Zucchini Using Modular Math

Math in the classroom was often joked about by our peers, while attending college, for lacking in real world application; however, we often apply the skill sets we learned in our daily lives. Just the other day we encountered an opportunity to apply modular arithmetic when sowing beans, cucumbers and zucchini. The beans and cucumbers were planted without trouble, but we did not have enough zucchini seeds to plant two entire beds with correct spacing. Since we were already in the field, and only few seeds shy we decided to simply alter the spacing to plant out one whole bed, without using all the seeds on hand.

### What is Modular Arithmetic?

If you can divide, you already know modular arithmetic, so breathe easy.  Modular arithmetic is all about the remainder of a simple division problem.  As a quick example, we will look at converting 27 to its' equivalent integer, whole number, in modulo 6.  The first step is to decide which order to divide: $27\div 6$ or $6\div 27$.  The easy rule to remember is that the modulo number will also be the denominator, that is, the bottom of the equation.  So, now we have the following:

$27\div 6=4$ rem $3$.

Therefore, 27 is equivalent to 3 modulo 6, often written as  $27\equiv3$ mod $6$.  Counting in modular arithmetic is simple as well.  For example, the integers included in modular 7 would be: $0, 1, 2, 3, 4, 5, 6$.  Notice that the numbers never include the modular number.  The Art of Problem Solving clearly states this rule: "for a natural number $n$ that is greater than 1, the modulo $n$ residues are the integers that are whole numbers less than $n$:

$0, 1, 2, \ldots, n-1.$"

Being able to perform division problems and count in modulo systems are the only techniques needed to follow along with this real-world example of modular arithmetic.  To read further about modular arithmetic, here are a few resources:

### The Problem...

Zucchini requires a six-inch spacing between plants when direct seeding into a garden plot.  The farm purchased four Costata Romanesco packets of seeds from Sow True Seed containing 12 seeds each for a total of 48 seeds.  Each garden plot is approximately 30 feet long.  Initially we set out to sow two 30-foot garden plots with the zucchini seeds, however, this would have required 60 seeds per bed for a total of 120 seeds needed.  Since we only had 48 seeds and wanted to get a bed planted right away, we altered our spacing to eight inches between seeds, ensuring we could plant the entire length of the bed.  Khori, having the Bachelor of Science in Applied Mathematics, was put on the task of laying down the measuring tape and placing seeds every eight inches (Khori knows her multiples of 8 better than William).  However, once we placed the measuring tape down near our sowing furrow, we noticed every foot reset - for example, instead of 13" the measuring tape displays 1".  The measuring tape "resetting" every foot meant we would have to count 1, 2, 3, 4, ..., 8 and repeat for every seed.

Modulo 12 Ruler

### The Solution...

We want to sow a zucchini seed every eight inches which still requires knowing multiples of 8: 0, 8, 16, 24, 32, 40, 48, ... .  Having previous knowledge of modular math, Khori quickly noticed that we could use modular math in order to quickly determine seed placement.  The multiples of 8 include 0, 8, 16, 24, 32, 40, 48, ... .  The ruler "resets" back to 0 at every 12 inches, therefore the ruler is in modulo 12.

#### Converting the Multiples of 8 to Modulo 12

Both 0 and 8 are less than 12, so these two numbers do not need to be converted.  However, the remaining multiples of 8 are larger than 12 (e.g. 16, 24, ...), therefore these numbers will require a little work.  Once we notice a pattern in the converted numbers, we can stop as the pattern will repeat.

16 mod 12: 16 - 12 = 4 or 16$\div$12 = 1 remainder 4

24 mod 12: 24 - 2*(12) = 0 or 24$\div$12 = 2 remainder 0

32 mod 12: 32 - 2*(12) = 8 or 32$\div$12 = 2 remainder 8

40 mod 12: 40 - 3*(12) = 4 or 40$\div$12 = 3 remainder 4

Starting with 0 and 8, we now have the multiples of 8 converted into modular 12: 0, 8, 4, 0, 8, 4, ... .  Notice the pattern "0, 8, 4" repeats.  The ruler being modular 12 implies that all multiples of 12 are equivalent to 0.  Therefore, we know to sow the first seed at the beginning of the ruler (0 inches), followed by the second seed at eight-inches.  The third seed is located at the next "4" mark following the "8" where the previous seed is located.  The image below starts at the "8" in the 0-8-4 pattern.  Notice the seed placement 8, 4, 0 (48 mod 12 $\equiv$ 0).

Thanks to modular math the zucchini seeds were sowed in no time at all!

Sowing Zucchini Using Mod 12