23. Fibonacci numbers {VeryLargeIntegers} | R Documentation |
Fibonacci Numbers Tools for vli Objects
Description
The Fibonacci Sequence is defined as follows:
x[1] = 0
,
x[2] = 1
,
...
x[n] = x[n-1] + x[n-2]
.
A positive integer is said to be a Fibonacci Number if it is an element of the Fibonacci Sequence.
The function Fibonacci(m, output)
computes and displays the first m
elements of the Fibonacci Sequence.
The function nthFibonacci(n)
computes and displays the n
-th element of the Fibonacci Sequence.
The function is.Fibonacci(x)
says whether or not x
is a Fibonacci Number.
Usage
Fibonacci(m, output = "print")
## Default S3 method:
Fibonacci(m, output = "print")
## S3 method for class 'numeric'
Fibonacci(m, output = "print")
nthFibonacci(n)
## Default S3 method:
nthFibonacci(n)
## S3 method for class 'numeric'
nthFibonacci(n)
## S3 method for class 'vli'
nthFibonacci(n)
is.Fibonacci(x)
## Default S3 method:
is.Fibonacci(x)
## S3 method for class 'numeric'
is.Fibonacci(x)
## S3 method for class 'vli'
is.Fibonacci(x)
Arguments
m |
object of class vli or 32 bits integer |
output |
chosen way for objects being returned: |
n |
vli class object or 32 bits integer |
x |
vli class object or 32 bits integer |
Value
The function Fibonacci(m, output)
returns a list of objects of class vli or the result displayed on the screen, depending on the output
argument.
The function nthFibonacci(n)
returns a object of class vli.
The function is.Fibonacci(x)
returns a boolean.
Author(s)
Javier Leiva Cuadrado
Examples
Fibonacci(200)
n <- as.vli("50000")
nthFibonacci(n)
x <- as.vli("5358359254990966640871840")
is.Fibonacci(x)
y <- x + 1
is.Fibonacci(y)