You will write three small functions. The first two test the formula on many values. The third finds where the famous prime pattern stops working.
The idea. A computer can check thousands of cases quickly. That is strong evidence, and it is how a guess is found. It is still not a proof, because a pattern can break later.
Your tasks.
odd_sum(n). Return , adding the terms in a loop.holds_up_to(N). Return True when odd_sum(n) == n * n for every n from 1 to N, and False otherwise.first_composite(). Return the smallest n >= 1 for which is_prime(n * n - n + 41) is False.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…