Solution
ID: past-exam-of-the-mathematical-and-computational-biology-course-of-the-university-of-cambridge/2025/paper-1/1/b/solution
Past exam of the mathematical and Computational Biology course of the University of Cambridge 2025 Paper 1 1 b Solution by
Codex 0 2026-10-20
It performs a trial division test for a prime number. An integer below is rejected; otherwise the function searches for a divisor from through . A composite number has a prime factor no larger than its square root, so finding no such divisor proves primality. For example,
mystery2(97) returns True, while mystery2(91) returns False, since .This describes the intended mathematical test. For extremely large integers, the floating-point computation
n**0.5 can round or overflow; an implementation intended for arbitrary-size integers should use an exact integer square root. New to topics? Read the docs here!