# Thread: Sums of squares of positive integers prime to n

1. ## Sums of squares of positive integers prime to n

Let $S(n)$ denote the sum of the squares of the positive integers $\leq n$ and prime to $n$.
Prove that
$\sum_{j = 1}^n{j^2} = \sum_{d \mid n}{d^2S\left(\frac{n}{d}\right)} = \sum_{d \mid n}{\frac{n^2}{d^2}S(d)}$

I have trouble with separating the integers $\leq n$ into classes, so that all integers $k$ such that $(k,n) = d$ are in the same class.
Thanks for the help.

2. Let $N=\{1^2,2^2,....n^2\}$, for each d|n, define $N_d=\{x^2x,n)=d\}" alt="N_d=\{x^2x,n)=d\}" />, then $\{N_d:d|n\}$ is a partion on N.
And for each $N_d$, Since $(\frac{x}{d},\frac{n}{d})=1$, By the definition of S(.), the sum of elements in $N_d$ is $d^2\times S(\frac{n}{d})$,
Thus,the first equality of $
\sum_{j = 1}^n{j^2} = \sum_{d \mid n}{d^2S\left(\frac{n}{d}\right)} = \sum_{d \mid n}{\frac{n^2}{d^2}S(d)}$

is proved.
When d exhaust all the divisors of n, so do $\frac{n}{d}$, Thus the second equality obviously hold.