Calculate Fibonacci Series

Contributed By: | Mon Jan 22 2024

Description
The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, typically starting with 0 and 1. In mathematical terms, the sequence is defined by the recurrence relation: F(n) = F(n-1) + F(n-2) with initial values F(0) = 0 and F(1) = 1. The sequence begins 0, 1, 1, 2, 3, 5, 8, 13, and so on. Fibonacci numbers have applications in various mathematical and scientific fields, and they often appear in nature and art.
Examples
Example: 1
Inputs:
n: 1
Required Result:
Output: 1
Example: 2
Inputs:
n: 3
Required Result:
Output: 2
Example: 3
Inputs:
n: 5
Required Result:
Output: 5
function Fibonacci(n) {
// Your code here
return 0;
}
Click run to execute these test cases.
Arguments:
nInvalid Argument, See help