P407
projecteuler.net

Idempotents

ℹ️Published on Sunday, 23rd December 2012, 10:00 am; Solved by 2752;
Difficulty rating: 20%

If we calculate $a^2 \bmod 6$ for $0 \leq a \leq 5$ we get: $0,1,4,3,4,1$.

The largest value of $a$ such that $a^2 \equiv a \bmod 6$ is $4$.
Let's call $M(n)$ the largest value of $a \lt n$ such that $a^2 \equiv a \pmod n$.
So $M(6) = 4$.

Find $\sum M(n)$ for $1 \leq n \leq 10^7$.



Soluzione

Last modified: May 01, 2025. Website built with Franklin.jl and the lovely Julia programming language.