Created
April 16, 2011 01:35
-
-
Save odiak/922757 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var sum = function () { | |
var memo = []; | |
return function (n, a, r) { | |
if (typeof memo[n] !== "undefined") { | |
return memo[n]; | |
} | |
return memo[n] = (n === 1 ? a : a + r * sum(n - 1, a, r)); | |
}; | |
}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment