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:

```ghci> fibsLen
1001

ghci> fibsUpTo 5
[1, 1, 2, 3, 5]

ghci> isFib 21
True

ghci> isFib 23
False

ghci> nthFib 6
8
```

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 one (1) 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 this list is `1`.

The last Fibonacci number in this 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 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 one (1) 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 this 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) or greater than the number of Fibonacci numbers in the `first1001Fibs` list, i.e., `fibsLen`.