MM250 DISCRETE MATH LAB Command Center

2. Number Systems

VERIFIED AGAINST MM250 MATERIAL

Sections: 2.1 · 2.2 · 2.3 · 2.4 · 2.5

CALCULATORVERIFIED AGAINST MM250 MATERIAL

Division Algorithm Calculator

§2.1 · Find q (n div d) and r (n mod d) such that n = qd + r, the mathematical way — not by truncation.

REMEMBER: negative modular arithmetic may behave differently from ordinary calculator division. Do not confuse Excel's QUOTIENT() with the mathematical division algorithm for negative integers. zyBooks confirms: -7 div 4 = -2 and -7 mod 4 = 1, since -7 = (-2)(4) + 1.
The course's Division Algorithm requires d to be a positive integer, with 0 ≤ r < d. This calculator enforces exactly that — d ≤ 0 is rejected rather than silently accepted as an extended capability.
CALCULATORVERIFIED AGAINST MM250 MATERIAL

Linear Combination Divisibility Helper

§2.1 · Verify: if x | y and x | z, then x | (sy + tz).

REMEMBER: this checks the rule "if x|y and x|z, then x|(sy+tz)" for the values you enter — it doesn't search for a linear combination on its own, and it isn't a general GCD/Extended-Euclidean teaching tool.
CALCULATORVERIFIED AGAINST MM250 MATERIAL

Modular Arithmetic Explorer

§2.2 · Compute n mod m, compare congruence, and use the modular operations family.

n mod m

Compare two numbers

Course ring: Z_m = {0, 1, 2, ..., m−1} for m > 1, with addition and multiplication mod m.

Modular addition / subtraction / multiplication

Subtraction is always well-defined in Z_m. Division is not — see the dedicated Modular Division tool below.

Mixed expression evaluator (mod precedence)

REMEMBER: mod has the same precedence as × and ÷ — all three bind tighter than + and −. 6 + 2 mod 7 = 6 + (2 mod 7) = 8, but 6 × 2 mod 7 = (6 × 2) mod 7 = 5.

Hashing: h(n) = cn mod T

CALCULATORVERIFIED AGAINST MM250 MATERIAL

Modular Division

§2.2 · a ÷ b mod m — only well-defined when b has a multiplicative inverse mod m.

REMEMBER: division is NOT a universal operation in every Z_m — try b=3, m=6 to see the "not well-defined" case the course contrasts with Z_5. The practical test is gcd(b, m) = 1.
CALCULATORVERIFIED AGAINST MM250 MATERIAL

Number Base Converter

§2.3 · Convert a number between any two bases (2–36), with expansion shown.

Course quick-convert (decimal → the bases the seminar demonstrates)

Broad 2–36 support above is a general calculator feature. These buttons jump straight to the specific bases MM250 uses (seminar example: 299 decimal = 453 base 8).

Hex digit reference: A=10, B=11, C=12, D=13, E=14, F=15

Base place-value relationship (appending a digit on the right)

Appending one digit shifts the old numeral one base-b place to the left (multiplying by b), then adds the new rightmost digit: new value = b·x + d. d is the digit being appended — not a digit count.

CALCULATORVERIFIED AGAINST MM250 MATERIAL

Number of Digits in Base b

§2.3 · How many digits does n need in base b?

Rule: digits = ⌈log_b(n+1)⌉, equivalently the k satisfying b^(k−1) ≤ n ≤ b^k − 1. Shortcuts: n = b^k needs k+1 digits; n = b^k − 1 needs k digits.
CALCULATORVERIFIED AGAINST MM250 MATERIAL

Text ↔ Numerical Message Translator

§2.3 · A=01...Z=26, space=27, period=28 — encode text to a number or decode a number back to text.

Text → Number

Number → Text

REMEMBER: the numerical message is treated as an integer — a single leading 0 is dropped when encoding, and must be restored (one 0 prepended, only if the digit count is odd) when decoding.
Code reference: A=01, B=02, ..., Z=26, space=27, period=28.
ASCII note: MM250 exercises also reference plain ASCII text/number conversion (e.g. 'A' = ASCII 65) — that's a separate, standard-library concept from this course-specific A=01...Z=26 scheme, and isn't duplicated here to keep this tool focused.
CALCULATORVERIFIED AGAINST MM250 MATERIAL

Caesar Cipher (Illustrative)

§2.4 · Shift-cipher encode/decode — a classic symmetric-key example.

REMEMBER: Caesar cipher is symmetric-key — the same shift number encrypts and decrypts (just in opposite directions). It's illustrative of the concept, not the RSA public-key system below.
CALCULATORVERIFIED AGAINST MM250 MATERIAL

Modular Exponentiation

§2.2 · Compute b^e mod m efficiently via square-and-multiply — the engine RSA runs on.

REMEMBER: never compute the full power first — 1211^859 has thousands of digits. Square-and-multiply keeps every intermediate value reduced mod N.
CALCULATORVERIFIED AGAINST MM250 MATERIAL

Linear Congruential Generator

§2.2 · X_(n+1) = (aX_n + c) mod m — a compact application of modular arithmetic.

STEPPERVERIFIED AGAINST MM250 MATERIAL

RSA Public-Key Cryptosystem

§2.5 · Full key generation, encryption, and decryption — exact zyBooks formulas.

1. Key generation

2. Encrypt / Decrypt a message

REMEMBER: compute keys first. Public key = (N, e) — used to encrypt. Private key = d — used to decrypt. zyBooks regression: p=31, q=59, e=859 → N=1829, φ=1740, d=79; message 1211 encrypts to 388 and decrypts back to 1211.
REFERENCEVERIFIED AGAINST MM250 MATERIAL

Cryptography Terminology Reference

§2.4–2.5 · Core vocabulary — see the RSA tool above and Caesar Cipher above for the working implementations.

Sender / Receiver
The party sending the message, and the party meant to read it.
Plaintext / Ciphertext
Plaintext is the original readable message; ciphertext is the scrambled result after encryption.
Encryption / Decryption
Turning plaintext into ciphertext, and turning ciphertext back into plaintext.
Secret key
The value that controls encryption/decryption (e.g. the shift in a Caesar cipher).
Symmetric-key concept
The same key is used to both encrypt and decrypt (see the Caesar Cipher tool above).
Public-key concept
Two different keys are used — one public (for encrypting) and one private (for decrypting) — so the receiver never has to share their decrypting key (see the RSA tool above).
RSA encryption / decryption
c = m^e mod N to encrypt; m = c^d mod N to decrypt. Fully implemented above.
Euler's φ (phi) function — RSA construction
For the two-prime RSA construction used in this course, φ = (p − 1)(q − 1). This is verified specifically for that construction — not presented here as a general Euler-phi calculator for arbitrary n.