← Quiz: Python Interview Programs: all 13 questions
Quiz: Python Interview Programs · Question 2 of 13
Why does the prime check loop only while i i <= n?
Why does the prime check loop only while i * i <= n?
- A.To avoid negative numbers
- B.Because any factor pair has one factor at most √n
- C.Because primes are less than √n
- D.It is just a style choice
Answer & explanation
Correct answer: Because any factor pair has one factor at most √n
If n = a × b with both a and b larger than √n, the product would exceed n.
Can you get the rest right without peeking?
Take the timed Quiz: Python Interview Programs quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →