Created
December 6, 2014 19:31
-
-
Save agar3s/21ef60d0867d19797352 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
var memo = { | |
'0': 0, | |
'1': 1, | |
'2': 2, | |
'3': 6 | |
}; | |
function main(n){ | |
if(n<=2){ | |
return memo[n]; | |
} | |
var n1 = memo[n-1] || main(n-1); | |
memo[n] = n*n1; | |
return memo[n]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment