← Complete problem index

PROJECT EULER · #0407

Idempotents

Statement only · SolvedOriginal problem ↗

If we calculate a2mod6 for 0≤a≤5 we get: 0,1,4,3,4,1.

The largest value of a such that a2≡amod6 is 4.
Let's call M(n) the largest value of a<n such that a2≡a(modn).
So M(6)=4.

Find ∑M(n) for 1≤n≤107.

Write-up coming later

The complete problem is available here. An approach, code, and answer will be added later.