Project Euler #6 in Java
A sum of first \$n\$ numbers is \$\frac{n(n+1)}{2}\$. A sum of squares of first \$n\$ numbers is \$\frac{n(n+1)(2n+1)}{6}\$. A difference in question is \$\frac{n^2(n+1)^2}{4} - \frac{n(n+1)(2n+1)}{6} = \frac{(n-2)(n-1)n(n+1)}{12}\$. 

This solution is likely the most efficient.