Skip to content

Code-Platoon-Assignments/algo-fibonacci

Repository files navigation

Fibonacci Sequence

One of the most popular coding challenges is to write an algorithm to return the n-th element in the Fibonacci sequence. Officially, the Fibonacci sequence is the integer sequence defined by the recurrence relation: F(n) = F(n-1) + F(n-2), where F(0) = 0 and F(1) = 1. For those of us who aren't math whizzes, the nth Fibonacci number is the sum of the prior two Fibonacci numbers.

Below are the first few values of the sequence:

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144...

Your challenge today is to write an algorithm that, given a number n, return the n-th Fibonacci Number. Keep in mind that the first two numbers in the fibonacci sequence are always [0,1]

Examples:

fibonacci(3); // 2
fibonacci(7); // 13

Usage

To install the pre-defined dependencies (including Jest)

npm install

To run just fibonacci.js

npm start

To run Jest

npm test

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •