Fibonacci sequence
Fibonacci sequence
fibonacci.m
This is a simple GNU Octave/Matlab function to compute the Fibonacci sequence or numbers. Function is vectorized.
Syntax
FIBONACCI(N) computes the Fibonacci number of N. N can be a scalar, vector or matrix of integers. Negative numbers are allowed (negafibonacci).
FIBONACCI without input argument returns the first 10 numbers of the Fibonacci sequence.
Examples
> fibonacci(7)
13
> fibonacci(0:10)
0 1 1 2 3 5 8 13 21 34 55
Documentation
Type doc fibonacci
or help fibonacci
for syntax and options. See also users comments and rating on .
References
https://en.wikipedia.org/wiki/Fibonacci_sequence
Author
Cite As
François Beauducel (2024). Fibonacci sequence (https://github.com/beaudu/fibonacci/releases/tag/v1.0), GitHub. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxTags
Acknowledgements
Inspired by: Fibonacci.m
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0 |