Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Consider the positive integers $\leq x$, then we know that there are $x/p + O(1)$ integers $\leq x$ that are $a \pmod{p}$ ($p$ prime).

Consider a similar problem, except this time, we are counting $(x, y) \in \mathbb{Z} \times \mathbb{Z}$ inside the box $|x| \leq B$ and $|y| \leq B$. I want to count the number of integers in this box with $x \equiv a \pmod{p}$ and $y \equiv b \pmod{p}$. Is the number of such pairs $4B^{2}/p^{2} + \text{error term}$. Is the error term $O(1)$ or $O(B)$? Can we have an error term of $O(1)$?

share|cite|improve this question

In fact, you don't need $p$ prime for this.

If we think about $p=3, a=1, b=1$ and let $B=3k$, the correct answer is $(2k-1)^2$ while our formula gives $4k^2$, with the error $4k \in O(B)$. Similarly if $B=3k+1$, the right answer is $(2k+1)^2=4k^2+4k+1$ while the formula gives $\frac {4(3k+1)^2}9 =\frac {36k^2+24k+1}9= 4k^2+ \frac {24}9k+\frac 19$ with error $\frac 43k \in O(B)$

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.