Simple and easy to use tools to work with the Fibonacci sequence.
To install this module through npm, simply use the following command:
$ npm install --save fibtastic
and then require it in your project like so:
// Nodeconst fibtastic = ;// Webpack;// Browser;
Using fibtastic is short and simple. Calculating the fibonacci sequence from the 10th to the 15th number is shown below:
const fibonacci = ;const sequence = fibonacci;console;// => [55, 89, 144, 233, 377, 610]
There are currently three methods that make up fibtastic with the above sequence included.
Sequence takes an object with an optional start time and a required end time and returns the fibonacci sequence from the specified start point to the end point with the start and end points included.
|number||start||Location in the fibonacci sequence to start||0|
|number||end||Location in the fibonacci sequence to stop||none (required)|
const sequence = fibonacci;console;// => [55, 89, 144, 233, 377, 610]// => [55, 89, 144, 233, 377, 610]
Value is used to find the fibonacci number at a specific point in the sequence.
|number||location||The location in the fibonacci sequence to retrieve the value from||none (required)|
const value = fibonaccivalue20;console;// => 6765
IsValue takes a value and check to see if that value is a part of the fibonacci sequence. If it is, it returns the location in the sequence where the value is and if it is not part of the fibonacci sequence it returns false.
Note: If the value is less than 2 but greater than 0,
isValue will just return true because the value 1 occurs in two locations in the fibonacci sequence and it is not possible to deduce which location is desired.
|number||value||The value to use to search the fibonacci sequence and find the location||none (required)|
const isValue = fibonacci;console;// => 20
const isValue = fibonacci;console;// => false
const isValue = fibonacci;console;// => true
To run the tests, use:
npm run test