| preferred AP College board partner for AP classes
hard Solved by 7 students
Primality Function Logical Error
< Prev
Next >

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.

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1jdvillalta86522 0m 54s 146
#2jasonvikathompson11 0m 16s 84
#3djy18102322 3m 26s -6
Items per page:
10
1 – 3 of 3
No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy