For each integer j relatively prime to n, let rj be the remainder when aj is divided by n. Then we have
aφ(n)=j=1(j,n)=1∏njaj=j=1(j,n)=1∏nj1(⌊naj⌋n+rj)=j=1(j,n)=1∏njrj(1+rjn⌊naj⌋)=j=1(j,n)=1∏n(1+rjn⌊naj⌋)
since {r1,r2,…,rφ(n)} is a reduced set of residues modulo n. Expanding the product and taking modulo n2, we obtain
aφ(n)≡1+nj=1(j,n)=1∑nrj1⌊naj⌋≡1+nj=1(j,n)=1∑naj1⌊naj⌋(modn2).
This implies
naφ(n)−1≡j=1(j,n)=1∑naj1⌊naj⌋(modn).