Hackerrank – Project Euler+ #006 – Sum square difference

Hackerrank – Problem description

The problem description – Hackerrank.

Solution

We calculate 3 equations for every number from 1 to N.

Sum of squares:

    \[1^2 + 2^2 + 3^3 + \cdots + {(n-1)}^2 + n^2 = S_1\]

Square of sum:

    \[{(1+2+3 + \cdots + (n-1) + n)}^2 = S_2\]

Result – Difference between sums:

    \[d = \| S_1 - S_2 \|\]

I created solution in:

All solutions are also available on my GitHub profile.

Java

Leave a Reply

Your email address will not be published. Required fields are marked *