🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Number Theory: all 9 questions

Quiz: Number Theory · Question 2 of 9

Why do programming problems ask for answers "modulo 10^9 + 7"?

Why do programming problems ask for answers "modulo 10^9 + 7"?

  1. A.The answer is always small
  2. B.To keep numbers bounded; addition and multiplication can be reduced mod m at every step
  3. C.Division is easier
  4. D.It makes the answer prime
Answer & explanation

Correct answer: To keep numbers bounded; addition and multiplication can be reduced mod m at every step

10^9 + 7 is a large prime that fits in 32 bits; mod rules keep intermediate results small.

Can you get the rest right without peeking?

Take the timed Quiz: Number Theory quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →