Trying to find a more... unconventional javascript answer :D
function squareSum(numbers) { if(numbers.length > 0) { let n = numbers.pop(); return square(n) + squareSum(numbers); } return 0; } let squares = [0, 1]; function square(n) { let absn = Math.abs(n); if(typeof(squares[n]) !== 'undefined') { return squares[n]; } let sqr = square(absn-1) + (absn-1) + absn; squares[n] = sqr; return sqr; }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Trying to find a more... unconventional javascript answer :D