sum of the n first squares=n(n+1)(2n+1)/6

sum of a geometrical serie=a1(rn-1)/(r-1)