2.1.1 • Published 4 years ago

fibtastic v2.1.1

Weekly downloads
38
License
MIT
Repository
github
Last release
4 years ago

NPM version Known Vulnerabilities npm NPM downloads Gitter

Installation

To install this module through npm, simply use the following command:

$ npm install --save fibtastic

and then require it in your project like so:

// Node
const fibtastic = require('fibtastic');

// Webpack
import * as fibtastic from 'fibtastic';

// Browser
import * as fibtastic from '/path/to/fibtastic.js';

Basic Example

Using fibtastic is short and simple. Calculating the fibonacci sequence from the 10th to the 15th number is shown below:

const fibonacci = require("fibtastic");

const sequence = fibonacci.sequence(10, 15);

console.log(sequence);
// => [55, 89, 144, 233, 377, 610]

API

There are currently three methods that make up fibtastic with the above sequence included.

sequence

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.

TypeOptionDescriptionDefault
numberstartLocation in the fibonacci sequence to start0
numberendLocation in the fibonacci sequence to stopnone (required)

Example:

const sequence = fibonacci.sequence(10, 15);

console.log(sequence);
// => [55, 89, 144, 233, 377, 610]
// => [55, 89, 144, 233, 377, 610]

value

Value is used to find the fibonacci number at a specific point in the sequence.

TypeOptionDescriptionDefault
numberlocationThe location in the fibonacci sequence to retrieve the value fromnone (required)

Example:

const value = fibonacci.value(20);

console.log(value); 
// => 6765

isValue

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.

TypeOptionDescriptionDefault
numbervalueThe value to use to search the fibonacci sequence and find the locationnone (required)

Examples:

const isValue = fibonacci.isValue(6765);

console.log(isValue); 
// => 20
const isValue = fibonacci.isValue(6770);

console.log(isvalue); 
// => false
const isValue = fibonacci.isValue(1);

console.log(isValue); 
// => true

Running Tests

To run the tests, use:

npm run test

License

MIT

2.1.1

4 years ago

2.1.0

4 years ago

2.0.5

4 years ago

2.0.4

4 years ago

2.0.3

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.9

5 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago