---
description: This summaries the reason why this modular exist.
---

# Why 10^9 + 7?

In most of the coding question, we would saw this specific magic number:

$$
10^9 + 7
$$

And they want us to modular this value. Once I wondered, why this value.

After been some research, there are few reasons why this particular number for that.

1. It is the first 10-digit prime number.
2. The number is large enough to verify the answer is correct, but not too large that causing some of the programming language can't output such large number or omit out some digits to gives wrong answer.
3. Prevent integer overflow.
4. If problem constraints are large integers, only efficient algorithms can solve them in an allowed limited time.

Any prime number less than $$2^{30}$$ will be fine in order to prevent possible overflows. If the output number is exponentially long that may hit $$2^{30}$$, the question will obligately request you to mod the answer into this magic number.

```python
MODULUS = 10 ** 9 + 7
Answer %= MODULUS
```
