Home / Fibonacci Sequence
Write a function that will return the nth term in the Fibonacci sequence, where n is the first parameter.
/**
* Returns the nth term in the Fibonacci sequence.
*
* @param {number} n - The position (1-based) in the Fibonacci sequence to retrieve.
* @returns {number} The nth Fibonacci number.
*/
function getFibonacci(n) {
// ...
}
console.log()
the input.n
is 0 or 1 then return n
.n
number of times.