You will write a small tool that tests a claim about whole numbers and reports the first counterexample.
The idea. A claim "for every from start to stop, " fails at the first with false. A search can find a counterexample, but it can never prove a claim about every whole number.
Your tasks.
is_prime(n). Return True for a prime and False otherwise (also for and ).first_counterexample(P, start, stop). Return the first in range(start, stop) with P(n) false, or None if there is none.euler to the first counterexample of " is prime" for from to .Run your code once to unlock the worked solution.
Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…