Skip to content

Instantly share code, notes, and snippets.

@naush
Created June 25, 2010 05:44
Show Gist options
  • Save naush/452470 to your computer and use it in GitHub Desktop.
Save naush/452470 to your computer and use it in GitHub Desktop.
var try_it = function(exception_logger) {
try {
fib_recursive(-1);
} catch(e) {
exception_logger.log(e.name, e.message);
}
}
function fib_recursive(n) {
if (n < 0) {
throw {
name: 'Invalid Argument',
message: 'Fib needs positive number'
};
}
return (n <= 1) ? n : fib_recursive(n - 1) + fib_recursive(n - 2);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment