3 ms·
I find that example rather discouraging. Generating a list of prime numbers is an interesting toy problem because it comes with certain expections. The trial di
by alan-crowe 16y ago
I find that example rather discouraging. Generating a list of prime numbers is an interesting toy problem because it comes with certain expections. The trial divisors are 2,3,5,7,9,... that is two and then odd numbers. One is supposed to stop early, when one reaches the square root of p, and one is supposed to detect this efficiently by looking at the quotinent and spotting that it is less than the trial divisor.
This makes for messy code in any language. Which is very much the point. Will the language help you with the messiness of real applications? If the example ducks the challenge, that is a strike against the language.