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. Articles by others on the same topic
There are currently no matching articles.