🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.To avoid negative numbers
  2. B.Because any factor pair has one factor at most √n
  3. C.Because primes are less than √n
  4. 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 →