Created
June 25, 2010 05:44
-
-
Save naush/452470 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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