Portability Portable Stable justin.hanekom@gmail.com Safe

Algorithm.Gutenberg.Fibonaccis

Description

Provides the first 1001 Fibonacci numbers, retrieved from the Gutenberg Project, along with functions to retrieve and query these numbers.

Examples:

````>>> ````fibsLen
```1001
```
````>>> ````fibsUpTo 35
```[1, 1, 2, 3, 5, 8, 13, 21, 34]
```
````>>> ````isFib 21
```True
```
````>>> ````isFib 23
```False
```
````>>> ````firstFib
```1
```
````>>> ````nthFib 6
```8
```
````>>> ````nthFib lastFib
```70330367711422815821835254877183549770181269836358732742604905087154537118196933579742249494562611733487750449241765991088186363265450223647106012053374121273867339111198139373125598767690091902245245323403501
```

Changes in 1.1.0:

Changes in 1.0.5:

• Updated and expanded documentation using Haddock markup

Synopsis

# Documentation

The `fibsLen` function returns the number of Fibonacci numbers in the `first1001Fibs` list.

As this list is based on the list of the first 1001 Fibonacci numbers as retrieved from the Gutenberg Project at http://www.ibiblio.org/pub/docs/books/gutenberg/etext01/fbncc10.txt it will be equal to `1001`.

If a subsequent version of this module uses a new, expanded list from the Gutenberg Project then this number will change accordingly.

Arguments

 :: Integer The maximum Fibonacci number to return -> [Integer] Returns all Fibonaccis below the threshold

The `fibsUpTo` function returns the list of Fibonacci numbers that are less than or equal to the given number.

An error is thrown if the number given is less than the minimum Fibonacci number represented by this module (i.e. `firstFib`) or greater than the maximum Fibonacci number represented by this module (i.e. `lastFib`).

`first1001Fibs` is a list of the first 1001 Fibonacci numbers.

The first Fibonacci number in the list is `1`.

The last Fibonacci number in the list is `70,330,367,711,422,815,821,835,254,877,183,549,770,181,269,836,358,732,742,604,905,087,154,537,118,196,933,579,742,249,494,562,611,733,487,750,449,241,765,991,088,186,363,265,450,223,647,106,012,053,374,121,273,867,339,111,198,139,373,125,598,767,690,091,902,245,245,323,403,501`.

Arguments

 :: Integer Returns the first Fibonacci number

The `firstFib` function returns the first Fibonacci number in the `first1001Fibs` list.

The first Fibonacci number in this list is `1`.

Arguments

 :: Integer The number to test -> Bool Returns whether or not the number is a Fibonacci

The `isFib` function returns whether or not the given number is a Fibonacci number.

An error is thrown if the number given is less than the minumum Fibonacci number represented by this module (i.e. `firstFib`) or greater than the maximum Fibonacci number represented by this module (i.e. `lastFib`).

The `lastFib` function returns the last Fibonacci number in the list of Fibonacci numbers, `first1001Fibs`.

The last Fibonacci number in the list is `70,330,367,711,422,815,821,835,254,877,183,549,770,181,269,836,358,732,742,604,905,087,154,537,118,196,933,579,742,249,494,562,611,733,487,750,449,241,765,991,088,186,363,265,450,223,647,106,012,053,374,121,273,867,339,111,198,139,373,125,598,767,690,091,902,245,245,323,403,501`.

Arguments

 :: Int The index of the Fibonacci number -> Integer Returns the requested Fibonacci number

The `nthFib` function returns the nth Fibonacci number.

An error is thrown if the index number given is less than one (`1`), the index of the first Fibonacci, or greater than the number of Fibonacci numbers in the `first1001Fibs` list, i.e., `fibsLen`.