Skip to content

Instantly share code, notes, and snippets.

@kwyn
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kwyn/9959842 to your computer and use it in GitHub Desktop.
Save kwyn/9959842 to your computer and use it in GitHub Desktop.
var f = [];
var factorial = function (n) {
if (n === 0 || n === 1){
return 1;
}
if (f[n] > 0){
return f[n];
}
f[n] = factorial(n-1) * n;
return f[n];
};
factorial();
@lexjacobs
Copy link

Opening quote on line 1 causing parsing error.
Suggested edit:
var f = [];

@kwyn
Copy link
Author

kwyn commented Jun 3, 2014

Cool, thanks for that catch! I will get this working correctly. E-mail me when you make changes. I get a flood of e-mails from github so these comments get lost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment