Last active
September 22, 2021 08:32
-
-
Save acushlakoncept/fa365d999679a8568b3fdca242eba2d3 to your computer and use it in GitHub Desktop.
Finding factorial using Dynamic Programming
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
const factorial = (n) => { | |
let memo = [] | |
memo[0] = 1 | |
for(let i = 1; i <= n; i++) { | |
memo[i] = i * memo[i - 1]; | |
} | |
return memo[n] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment