← 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"?
- A.The answer is always small
- B.To keep numbers bounded; addition and multiplication can be reduced mod m at every step
- C.Division is easier
- 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 →