Skip to main content

Exercises

Complete the proof-and-trace practice, then implement all six lab functions. For each function record its accepted domain, output contract, failure behavior and one mathematical reason it works.

Required boundary families: negative inputs, one zero input, both gcd inputs zero, modulus one, invalid moduli, noninvertible coefficients, empty solution lists, multiple solutions, exponent zero and prime squares.

For independent transfer, choose a cycle size and stride not used in the examples. Predict reachability before running the program; then change just the stride so the reachable set changes. Write why this is a changed model, not merely another input with the same answer.

Optional extension: solve a pair of congruences with coprime moduli and verify uniqueness modulo their product (Chinese remainder theorem), or implement a sieve and compare its workload with repeated trial division. These are not required exit gates or included in the core time allowance.