The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Mark Elston (133) [Avatar] Offline
#1
In this capstone you have a precomputed list of prime numbers in a list. The list contains 1229 elements with the maximum prime number being 9973.

In the isPrime function, however, you return None for any values greater than the length of the list. This means, for example that isPrime 9973 returns Nothing. This is not correct. It should return None for any values greater than the maximum value in the list.

Also, in the tests prop_primesArePrime and prop_nonPrimesAreComposite, you test for divisors up to val - 1. For efficiency I think you can change that to val `div` 2 since anything greater than that cannot be a divisor of val anyway.