Primality Function Logical Error
A programmer has written a function to determine if a number is prime. The function correctly identifies 2, 3, 5, and 7 as prime, but incorrectly says 9 is prime and 11 is not prime. Based on these test results, what is the most likely error in the algorithm’s logic?
A
The function rejects all numbers above 7 regardless of tests.
B
It returns true if a number is not divisible by 2 or 3 only.
C
It does not check divisibility by all possible numbers up to the square root.
D
Only odd divisors greater than 3 are skipped by the function.
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | jdvillalta865 | 2 | 2 | 0m 54s | 146 |
| #2 | jasonvikathompson | 1 | 1 | 0m 16s | 84 |
| #3 | djy181023 | 2 | 2 | 3m 26s | -6 |
Items per page:
10
1 – 3 of 3
APFIVE