Created
August 12, 2016 18:35
-
-
Save cullen-tsering/f8bbbb0671934580666612f2791a3175 to your computer and use it in GitHub Desktop.
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
/* | |
ways to calculate the number of blocks of used to build a pyramid | |
*/ | |
var numberOfBlocksInPyramid = function(edgeLength,intialCount) { | |
if (edgeLength==0) return intialCount; | |
var atLevel=edgeLength*edgeLength; | |
console.log(edgeLength + " " + atLevel + " " + intialCount); | |
intialCount=atLevel+intialCount; | |
return numberOfBlocksInPyramid(--edgeLength, intialCount); | |
} | |
console.log("Level @LevelCount Balance"); | |
console.log("Total: " + numberOfBlocksInPyramid(210,0)); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment