BS Artificial Intelligence · Semester 1 · Week 07

Discrete Mathematics for BSAI

Introductory Number Theory and Midterm Synthesis

Dr. Hira Benish
Associate Professor & HoD, Mathematics
PMAI Lab, Mathematics Behind AI

Week 7 · Dr. Hira BenishBegin reading  

01 · Opening Scenario: Packs and Cycles

A coordinator has 24 red cards and 18 blue cards. She wants the greatest possible number of identical packs with no cards left over. A separate weekly rota starts on Monday as Day 0. Which weekday is Day 17?

Predict first: Six packs work: each contains 4 red and 3 blue cards. Day 17 is Thursday if Day 0 is Monday. How can we justify the greatest pack count, and why does a seven-day cycle lead to Thursday?

Two mathematical questions

Which positive whole number divides both counts? What remains after complete cycles of seven? Divisibility, greatest common divisors and modular arithmetic make these answers precise.

02 · Learning Objectives and Three-Hour Guide

By the end of Week 7, you should be able to test divisibility; distinguish primes from composite numbers; find a small greatest common divisor; perform the Euclidean algorithm; calculate a remainder; interpret a≡b (mod m); and choose a suitable idea from Weeks 1–7 for a short mixed problem.

Class timeEssential work
35 minDivisibility and primes
35 minGCD and Euclidean algorithm in pairs
40 minRemainders, clock game and explanation
50 minIntegrated revision across Weeks 1–7
20 minUngraded diagnostic and feedback

Classroom essentials Sections 01–10 and 13–14. Optional self-study The toy check-code illustration and Colab verification. The diagnostic reveals what to revise; it is not the Week 8 midterm.

03 · Divisibility Means No Remainder

When 18 cards can be arranged in equal groups of 3 with none left, we say 3 divides 18, written 3∣18. In general, for a nonzero integer a, a∣b means there is an integer k with b=ak. For example, 18=3×6, so 3∣18.

ClaimCheckVerdict
4∣2424=4×6True
5∣2424=5×4+4False; 4 left over
6∣1818=6×3True

The vertical bar in 3∣18 says “divides”; it is not a fraction. A multiple of 3 has the form 3k, while a divisor of 18 is a number that divides 18 exactly.

04 · Primes Are the Basic Positive Factors

A prime is a positive integer greater than 1 with exactly two positive divisors: 1 and itself. A positive integer greater than 1 with more than two positive divisors is composite. The number 1 is neither prime nor composite.

Sort small numbers

2 is prime: its positive divisors are 1 and 2. 13 is prime: only 1 and 13 divide it. 15 is composite because 15=3×5. The number 2 is the only even prime: every larger even number is divisible by 2 and has another positive divisor.

Quick check: Is 1 prime because it has no “other” divisor? No. The definition requires exactly two positive divisors; 1 has only one.

05 · The Greatest Common Divisor

A common divisor divides both numbers. The greatest common divisor, written gcd(a,b), is the largest positive common divisor. For the opening scenario, the positive divisors of 24 are {1,2,3,4,6,8,12,24}; those of 18 are {1,2,3,6,9,18}. Their common divisors are {1,2,3,6}, so gcd(24,18)=6.

24÷6=4 red cards and 18÷6=3 blue cards per pack.

Why does the GCD give the greatest number of identical packs? If there are d packs with no leftovers, d must divide both 24 and 18. The largest allowed d is their GCD. This interpretation counts packs, not cards per pack.

06 · Find a GCD Without Listing Every Divisor

For larger numbers, divide and keep the remainder. Replacing the larger number by its remainder with the smaller number does not change the common divisors. For example, a number dividing both 84 and 30 also divides 84−2(30)=24; the reasoning works in reverse as well. Thus gcd(84,30)=gcd(30,24).

Division stepQuotientRemainder
84=30×2+24224
30=24×1+616
24=6×4+040

Stop when the remainder becomes 0. The last nonzero remainder is 6, so gcd(84,30)=6. Each new remainder is smaller than the previous divisor, so this process finishes for positive starting numbers.

Pair task: Complete gcd(30,18) by writing each division step. Explain why the final answer divides both starting numbers.

07 · What Remains After Full Cycles?

For an integer a≥0 and a positive integer m, write a=qm+r with 0≤r<m. Here q counts complete groups of size m, and r is the remainder. We write a mod m=r.

Worked cycle

17=2×7+3, so 17 mod 7=3. Two full weeks use 14 days, leaving 3 days after the starting weekday.

A remainder of 0 means exact divisibility: 7∣21 and 21 mod 7=0. A remainder under 0 or at least m cannot be the final remainder in this nonnegative setting.

08 · A Seven-Day Remainder Clock

Start with Monday as Day 0. Every complete group of seven returns to Monday. The remainder tells us how far to move from that starting position.

Seven-day cycle: remainders zero through six correspond to Monday through Sunday, and Day 17 has remainder three, Thursday 0Mon 1Tue 2Wed 3Thu 4Fri 5Sat 6Sun 17 = 2×7 + 3 → Thursday
Figure 1. The labels repeat after seven steps; Day 17 and Day 3 occupy the same position in the cycle.

Check Day 24: 24=3×7+3, so it is also Thursday. The day number differs, but the position in the seven-day cycle matches.

09 · Same Remainder, Same Position

We write a≡b (mod m) when a and b have the same remainder upon division by positive m. Equivalently, m∣(a−b). For instance, 17≡3 (mod 7) because both leave remainder 3 and 17−3=14 is divisible by 7. Also 24≡17 (mod 7).

Do not read ≡ as ordinary equality: 17≠3 as integers, yet they occupy the same position in a seven-day cycle. Always state the modulus.

For a fixed modulus, “has the same remainder” groups nonnegative integers into classes. This connects to last week’s equivalence relations: every number shares its remainder with itself; matching is symmetric; and two matches in a chain give another match.

10 · Number Detective

Classroom activity · Predict → Test → Explain Use the remainder clock first. Then complete the Euclidean algorithm one division at a time. The controls reveal examples; your written reason should explain the rule.

Remainder clock

Euclid stepper · gcd(84,30)

Before revealing each row, predict the quotient and remainder.

    Which is the GCD?

    Choose after predicting the last nonzero remainder.

    11 · A Small Check-Code Illustration

    Self-study A toy form stores three digits followed by a check digit. Its stated rule is: add the first three digits and take the remainder on division by 5. For 3,4,2, the sum is 9, and 9 mod 5=4, so the valid toy code is 342-4.

    If a form receives 342-3, the check fails under this rule. But a matching check digit does not guarantee a correct or authentic message: 347-4 also passes because 3+4+7=14 and 14 mod 5=4. This small rule demonstrates remainders; it is not a secure authentication method.

    12 · Optional Colab Verification

    Self-study · mathematics first Predict the outputs from the written divisions. In Python, % returns the remainder for these nonnegative inputs.

    print(17 % 7)
    print(24 % 7)
    print(21 % 7)

    Expected outputs: 3, 3, 0 on separate lines. After completing the Euclidean algorithm by hand, you may use the standard math library to check it. The import line makes its ready-made gcd function available; it does not explain the calculation for you.

    from math import gcd
    print(gcd(84, 30))

    The output 6 confirms the hand result for this case. The written steps remain the mathematical work.

    13 · Midterm Synthesis: Choose the Right Tool

    50-minute guided revision Discuss each prompt, state the earlier week’s idea, and give one justified line. These are review problems, not new topics.

    PromptWhat to decide
    A · A system states P→Q and knows P.Does Q follow? Would knowing Q alone establish P?
    B · “Every positive even number is divisible by 4.”Prove or disprove with a suitable method.
    C · Assume 1+3+···+(2k−1)=k².What next term establishes the case k+1?
    D · f:{1,2,3}→{1,2} sends 1→1, 2→1, 3→2.Is it a function? One-to-one? Onto?
    E · Group {0,1,2,3,4,5} by the same remainder mod 3.Find the classes. Which relation property gives groups?
    F · Calculate gcd(30,18).Write divisions and justify the final remainder.

    Suggested pacing: 6 minutes each for A–E, 8 minutes for F, 12 minutes for peer explanations and corrections. The connection in E links Week 6 equivalence classes with this week’s remainders.

    14 · Twenty-Minute Diagnostic

    Ungraded check and feedback Spend about 12 minutes answering and 8 minutes comparing reasons. Write a calculation or counterexample, not just a final value.

    1. Is 1 prime, composite, or neither? Why?
    2. Does 5∣31? Give a quotient and remainder.
    3. Find gcd(21,14).
    4. Calculate 23 mod 7.
    5. Is 23≡9 (mod 7) true? Give two ways to check.

    Mark a topic to revisit before Week 8: divisibility and primes / GCD steps / remainder and congruence / an earlier week’s reasoning.

    15 · Common Mistakes

    Tempting moveRepair
    Call 1 prime.A prime has exactly two positive divisors; 1 has one.
    Reverse the meaning of a∣b.Check whether b=a×k for an integer k.
    Choose 0 as the GCD after the algorithm stops.Use the last nonzero remainder.
    Let the final remainder equal the modulus.A remainder must be from 0 to m−1.
    Read a≡b (mod m) as a=b.Compare their remainders or check m∣(a−b).
    Assume a toy check code proves authenticity.It checks only the stated remainder rule; collisions are possible.

    16 · Summary

    • a∣b means b=ak for an integer k; primes have exactly two positive divisors.
    • The GCD is the largest positive common divisor. The Euclidean algorithm repeatedly replaces a pair by the smaller number and the remainder.
    • For a=qm+r with 0≤r<m, a mod m=r. Equal remainders give a congruence modulo m.
    • A cyclic schedule is a genuine use of remainders. A short computation can check an example, while the written reasoning explains it.
    • The midterm review connects logic, proof, sets, functions, relations and number theory without adding a new mathematical topic.

    17 · Visual Concept Map

    Divisibility connects to primes and common divisors; division gives remainders and congruence for cycles DIVISIONa=qm+r REMAINDER 0divisibility → primes, common divisorsGCD → Euclidean algorithm REMAINDER rsame r → congruencecycles → repeated positions
    One division statement supports exact divisibility and reasoning about what remains.

    18 · Key Terms

    Divisor; multiple
    If a∣b, a is a divisor of b and b is a multiple of a.
    Prime; composite
    Greater than 1 with exactly two positive divisors; greater than 1 with more than two.
    GCD
    Largest positive integer dividing both given integers.
    Euclidean algorithm
    Repeat division with remainders until 0; the previous remainder is the GCD.
    Modulus; remainder
    Positive group size m; the value r with 0≤r<m after complete groups.
    Congruence
    Same remainder for a stated modulus.

    19 · Looking Ahead

    Week 8 is the midterm examination only. It introduces no new mathematical material. Use the diagnostic and selected solutions to identify one or two topics to revisit from Weeks 1–7.

    Selected Solutions

    Number Detective

    17=7×2+3, so Thursday. 24=7×3+3 is also Thursday. Euclid: 84=30×2+24; 30=24×1+6; 24=6×4+0. The last nonzero remainder, 6, is the GCD; 0 only signals that the algorithm has stopped.

    Pair task · gcd(30,18)

    30=18×1+12, 18=12×1+6, 12=6×2+0; hence gcd(30,18)=6. Both 30 and 18 are multiples of 6.

    Midterm synthesis A–C

    A: Q follows from P and P→Q; Q alone need not establish P. B: False, since 6 is positive and even but not divisible by 4. C: Add the next odd term 2k+1; k²+2k+1=(k+1)².

    Midterm synthesis D–F

    D: It is a function and onto {1,2}; not one-to-one because 1 and 2 share output 1. E: Classes {0,3}, {1,4}, {2,5}; same remainder is an equivalence relation, so its classes partition the set. F: 30=18+12, 18=12+6, 12=2×6+0, so GCD 6.

    Diagnostic 1–5

    1: Neither; 1 has only one positive divisor. 2: No, because 31=5×6+1. 3: gcd(21,14)=7. 4: 23=7×3+2, so remainder 2. 5: True: both 23 and 9 leave remainder 2 on division by 7, and 23−9=14 is divisible by 7.