Combining Letter Numbers With Modulo Math

TL;DR: After A1Z26 encoding, apply mod 26 (or mod 26 with +1 offset) to wrap values for Caesar-style numeric ciphers. Always agree whether alphabet is 1–26 or 0–25 before modding.

Why modulo enters ciphers

Shifting numbers without wrap produces values above 26 or below 1. Mod arithmetic keeps outputs in valid letter range when defined correctly.

Mod 26 on 1–26 indexing

Adding 3 to 25 yields 28. If alphabet wraps Z→A, define wrap function explicitly: ((v − 1 + shift) mod 26) + 1. Off-by-one bugs flip entire messages.

Spreadsheet formula pattern

For shift 3 encode: =MOD(A1+3-1,26)+1 where A1 holds A1Z26 value. Decode: =MOD(A1-3-1,26)+1. Test on A and Z edge cases before filling down.

Negative shifts

Subtracting 5 from 2 (B) needs mod that handles negatives: ((2 − 1 − 5) mod 26) + 1 = 22 (V). Hand calculation errors love small numbers at start of alphabet.

Relation to Vigenère

Repeating keyword shifts per letter use same mod machinery with changing shift amount each position. Master fixed shift before variable keyword streams.

Verify round trip

Encode HELLO with shift 7, decode with shift −7 (or +19). Mismatch implicates mod definition, not spelling.

Tool boundary

Plain letterstonumbers.com outputs unshifted A1Z26. Apply mod shifts in spreadsheet or script layer; document pipeline on homework.

Puzzle hunt notation

Clue “ROT3 on positions” after A1Z26 means mod shift. Clue “ROT3 on letters” might mean Caesar before numbering—order matters.

Programming pitfall

Python % behaves differently on negatives than math mod in some languages. Use consistent library helpers in club coding challenges.

Teaching mod with clock analogy

Hours mod 12 map to letter wrap mod 26. Students grasp wrap faster on clocks than formulas alone.

Mod 26 formula on 1-based values

((v − 1 + shift) mod 26) + 1 prevents off-by-one wraps at Z. Spreadsheet template beats hand arithmetic on long messages.

Negative shift handling

Subtracting five from B (2) needs mod that supports negatives: ((2−1−5) mod 26)+1 = 22 (V).

Vigenère preview without full table

Repeating keyword shifts per letter reuse same mod machinery with changing shift amount each position.

Round-trip verification

Encode HELLO shift 7, decode shift −7. Mismatch implicates mod definition, not spelling.

Tool boundary clarity

https://letterstonumbers.com/ outputs plain A1Z26. Apply shifts in spreadsheet layer; document pipeline on homework header.

Wrapping PLANET after a plus-seven shift

PLANET sits in a friendly part of the alphabet until the shift is large. P is 16, L is 12, A is 1, N is 14, E is 5, T is 20. Add 7: 23, 19, 8, 21, 12, 27. The last value, 27, wraps. Subtract 26 and it becomes 1. The shifted row is 23 19 8 21 12 1, which spells WSHULA. Keep both rows on the board. Students who wrap by taking modulo 26 on the raw sum often turn 26 itself into 0, and 0 is not a letter in the 1-based map. The classroom rule for this exercise is: subtract 26 when the sum exceeds 26; if you ever see 0, add 26 back.

Check the wrap with a single letter before you shift the whole word. T plus 7 is 27, which becomes A, not a blank. Z plus 7 is 33. Subtract 26 once and you get 7, which is G. You do not subtract 26 twice. Write 33, then 7, on the board so the “once” is visible. Teams who subtract until the number “looks small” will turn 33 into 7 and then into something else if they keep going.

Spreadsheet column for the same PLANET shift

In a sheet, column A holds the letters P L A N E T. Column B holds the plain positions 16, 12, 1, 14, 5, 20. Column C holds the formula that adds 7 and, if the result is greater than 26, subtracts 26. Do not use a programming modulo that yields 0 for multiples of 26. Test the formula on a lone Z in row 8. The expected result is G, value 7. If the cell shows 0 or an error, the formula is using the wrong base and every word you shift later will be quietly wrong.

Freeze the header row and label column C “plus 7, 1-based wrap.” A classmate who copies the sheet next term will change the 7 without reading your mind. The label makes the key portable. Decode column C back through the inverse, minus 7 with a wrap the other way, and confirm PLANET returns. That round trip is the grade, not the presence of a formula.

Single-cell Z test before PLANET is filled down

Before anyone fills the formula down the PLANET column, type Z in a sandbox cell and confirm plus-seven returns 7. Then type A and confirm it returns 8, which is H. A and Z are the two edges. A sheet that passes both edges will handle T, which wraps in PLANET, and P, which does not. A sheet that fails Z will still look fine on P, L, A, N, and E, and the error will hide in the last letter until someone decodes WSHUL and wonders where the final letter went.

Save the sandbox cells. Do not delete them to “clean the sheet.” Next month’s edit will change the shift from 7 to 9, and the edges will move. The sandbox is how you notice. Label it “do not grade.” Students should not think the Z row is part of the word.

Plus-nine pass on FROST before the column is filled

FROST is short enough to check by hand and long enough to hide a wrap that only hits the later letters. F is 6, R is 18, O is 15, S is 19, and T is 20. Add 9: the raw sums are 15, 27, 24, 28, and 29. Subtract 26 once from each sum that is greater than 26. The kept row is 15, 1, 24, 2, 3, which spells OAXBC. The O in the middle of FROST does not wrap, because 15 plus 9 is 24 and 24 is still a letter. R, S, and T do wrap. Students who subtract 26 from every cell will change the 15 and the two rows will disagree.

Run the same plus-nine rule on a lone Z in a sandbox cell before anyone fills FROST down a column. Z is 26, plus 9 is 35, minus 26 once is 9, which is I. If that cell shows 0, the formula treats a multiple of 26 as a blank, and every later wrap will be quietly wrong. Fix the sandbox, then fill the column, then add 9 in reverse and confirm the letters come back as FROST.