Project Euler problems (numbering) : follow naming convention.

This commit is contained in:
Eric Lavault
2021-10-11 16:17:25 +02:00
parent df4a783b06
commit cb6201f03f
11 changed files with 2 additions and 2 deletions

View File

@ -0,0 +1,11 @@
// https://projecteuler.net/problem=6
export const squareDifference = (num = 100) => {
let sumOfSquares = 0
let sums = 0
for (let i = 1; i <= num; i++) {
sumOfSquares += i ** 2 // add squares to the sum of squares
sums += i // add number to sum to square later
}
return (sums ** 2) - sumOfSquares // difference of square of the total sum and sum of squares
}