Skip to content

Instantly share code, notes, and snippets.

@acushlakoncept
Last active September 22, 2021 08:32
Show Gist options
  • Save acushlakoncept/fa365d999679a8568b3fdca242eba2d3 to your computer and use it in GitHub Desktop.
Save acushlakoncept/fa365d999679a8568b3fdca242eba2d3 to your computer and use it in GitHub Desktop.
Finding factorial using Dynamic Programming
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