Skip to content

Instantly share code, notes, and snippets.

Yoav Rubin yoavrubin

Block or report user

Report or block yoavrubin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@yoavrubin
yoavrubin / factorial.js
Created Dec 12, 2013
A trip down factorial lane - see what Javascript functions and some functional programming goodies can do
View factorial.js
// the most basic factorial
function fact1(n){
if(n < 2) return 1;
return n*fact1(n-1);
}
// let's add some precondition verifications
function fact2(n){
if(typeof n !== 'number' || isNaN(n) || n < 0)
You can’t perform that action at this time.