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

Find the number of solutions of $x^2=x\mod m$ for any integer $m$.

I was thinking about bringing the $x$ over to the other side and somehow apply chinese remainder thm.

share|cite|improve this question

Start with

$$ x^2 - x = x(x-1) \equiv 0 \mod m $$ Now, if $m=p^an$, where $p$ is a prime and $p\not| n$, then you can write that $$ x(x-1) \equiv 0 \mod p^a $$ Determine under which conditions you get a solution to this, and repeat for each prime factor of $m$. Then consider the total number of solutions based on the same reasoning as the Chinese Remainder Theorem (no need to actually use the theorem, unless you're finding all of the solutions).

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.