Project Euler Problem 6: Sum square difference
I don't know about the difference between sumOfTheSquares += i*i and Math.pow() but the sum of squared of first n natural numbers is as follows 

\$ 1^2 + 2^2 + 3^2 + 4^2 = \dfrac{n(n+1)(2n+1)}{6}\$ 

So its faster than using a for loop    

Edit: General way to prove this is to use mathematical induction
Here's a link!