← Complete problem index

PROJECT EULER · #0407

Idempotents

Statement only · SolvedOriginal problem ↗

If we calculate a2mod6 for 0a5 we get: 0,1,4,3,4,1.

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

Find M(n) for 1n107.

Write-up coming later

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