The 6th problem is: The difference between the sum squared and the squared sum of proceeding numbers. We can solve this purely analytically:

x=i=1ni2(i=1ni)2 x = \sum_{i=1}^n i^2 - \left( \sum_{i=1}^n i \right)^2

We now apply the Faulhaber formulars

x=n33+n22+n6(n2+n2)2 x = \frac{n^3}{3} + \frac{n^2}{2} + \frac{n}{6} - \left( \frac{n^2+n}{2} \right)^2

=n36n44+n24+n6 = -\frac{n^3}{6} - \frac{n^4}{4} + \frac{n^2}{4} + \frac{n}{6}

=n24(1n2)+n6(1n2) = \frac{n^2}{4} \cdot \left(1-n^2 \right) + \frac{n}{6} \cdot \left(1-n^2 \right)

=n12(3n+2)(1n2) = \frac{n}{12} \cdot \left( 3n + 2 \right) \cdot \left( 1 - n^2 \right)


Published

Category

projecteuler

Tags