Function Math Arithmetic Class

Fibonacci

Return the Nth Fibonacci number as specified in vX. Every Fibnonacci number is the sum of the previous two numbers in the sequence, except for the first two numbers which are both 1 (one). vX must be between 1 and 1476.

Signature (Visual Basic / VBA)

Public Function Fibonacci( _
    ByVal vX As Variant _
    ) As Variant

Code Example

    Fibonacci(0) = 0
    Fibonacci(1) = 1
    Fibonacci(2) = 1
    Fibonacci(3) = 2
    Fibonacci(4) = 3
    Fibonacci(5) = 5
    Fibonacci(6) = 8
    Fibonacci(7) = 13

Parameters

Parameter Description
vX The sequence number of the Fibonacci number to be returned. Function returns Null if vX is Null of cannot be fixed up to a number. Function returns 0 (zero) if vX is < 1 (less than one). Function returns Null if vX is greater than 1476.