I take no shame in reading a few lisp solutions to spoil my answer. With every year, I find a new way of looking at data that uncovers new possible "cheats".
Just like my favorite solution to the sum of squares problem (the sum of the squares from 1 to n): m * (m + 1) * (2*m + 1) / 6
I take no shame in reading a few lisp solutions to spoil my answer. With every year, I find a new way of looking at data that uncovers new possible "cheats".
Just like my favorite solution to the sum of squares problem (the sum of the squares from 1 to n):
m * (m + 1) * (2*m + 1) / 6
Didn't know about this equation. Also you may have accidentally written
m
instead ofn
in the formula :) .Whoops! The notes I have it in mark it as ‘partial sum(n2) for 1 to m = ...` (copied from wolfram alpha)