Number theoryDifficulty 5.5AIME, harderProve itBrazil
Let σ(n) be the sum of all positive divisors of n, where n is a positive integer (for instance, σ(6)=12 and σ(11)=12). We say that n is almost perfect if σ(n)=2n−1 (for instance, 4 is almost perfect since σ(4)=7). Let nmodk be the remainder of the division of n by k and s(n)=∑1≤k≤nnmodk (for instance, s(6)=0+0+0+2+1+0=3 and s(11)=0+1+2+3+1+5+4+3+2+1+0=22). Prove that n is almost perfect if and only if s(n)=s(n−1).