mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-19 10:05:41 +08:00
9 lines
263 B
JavaScript
9 lines
263 B
JavaScript
// https://projecteuler.net/problem=6
|
|
|
|
export const squareDifference = (num = 100) => {
|
|
let sumOfSquares = (num)*(num+1)*(2*num+1)/6
|
|
let sums = (num*(num+1))/2
|
|
|
|
return sums ** 2 - sumOfSquares // difference of square of the total sum and sum of squares
|
|
}
|