Fibonacci

<< Click to Display Table of Contents >>

Navigation:  ThinBASIC Modules > Math > Calculation >

Fibonacci

 

Description

 

Given a number N, this function returns the n-th Fibonacci Number.

 

The Fibonacci numbers are the numbers in the following integer sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ... where each number is the sum of the 2 preceding numbers.

 

Syntax

 

n = Fibonacci(N)

 

Returns

 

Number.

 

Parameters

 

Name

Type

Optional

Meaning

N

Number

No


 

Remarks

 

For fast calculation and avoid recursion. this function uses the following internal formula:

 

n = ((1 + Sqr(5))^N - (1 - Sqr(5))^N)  / (2^N * Sqr(5))

 

Restrictions

 

N parameter MUST be in range 0 to 92 to give a valid result.

 

See also

 

Examples