Sum of squares function
The sum of squares function is an arithmetic function that gives the number of representations for a given positive integer n as the sum of k squares, where representations that differ only in the order of the summands or in the signs of the square roots are counted as different, and is denoted by rk(n).
Definition
The function is defined as
where |.| denotes the cardinality of the set.
Particular cases
The number of ways to write a natural number as sum of two squares is given by r2(n). It is given explicitly by
where d1(n) is the number of divisors of n which are congruent with 1 modulo 4 and d3(n) is the number of divisors of n which are congruent with 3 modulo 4.
The number of ways to represent n as the sum of four squares was due to Carl Gustav Jakob Jacobi and it is eight times the sum of all its divisors which are not divisible by 4, i.e.