Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const factorial = n => {
let f = 1;
while (n > 0) {
f = f * n;
n = n - 1;
}
return f;
};
factorial(1); // => 1
factorial(2); // => 2
factorial(3); // => 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.