Created
September 14, 2015 16:38
-
-
Save jluismm2311/33698929ec7a8d9fffb4 to your computer and use it in GitHub Desktop.
Feynman's squares Richard Phillips Feynman was a well-known American physicist and a recipient of the Nobel Prize in Physics. He worked in theoretical physics and pioneered the field of quantum computing. Recently, an old farmer found some papers and notes that are believed to have belonged to Feynman. Among notes about mesons and electromagneti…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function countSquares(n){ | |
let value = 0; | |
for(var i = 1; i<=n; i++){ | |
value += i * i; | |
} | |
return value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
function countSquares(n) { return (n*(n+1)*((n<<1)+1)/6); }