Get fibonacci numbers using JavaScript function

//Returns a Fibonnaci number
//@param n is an integer
function fibonacci(n)
{
if(n < 0)
{
return 0;
}
else if(n <= 2)
{
return 1;
}
else
{
return fibonacci(n - 1) + fibonacci(n - 2)
}
}
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *