This site is supported by donations to The OEIS Foundation.
Template:Fibonacci/doc
From OeisWiki
Fibonacci}} mathematical function template returns the
th Fibonacci number, where
is an integer. It uses Binet’s closed-form formula for the Fibonacci numbers.
The {{n |
n |
Contents
Usage
- {{Fibonacci|integer}}
Valid input
An integer argument.
Examples
Examples with valid input
Code Result {{Fibonacci|-5}} 5 {{Fibonacci|-4}} -3 {{Fibonacci|-3}} 2 {{Fibonacci|-2}} -1 {{Fibonacci|-1}} 1 {{Fibonacci|0}} 0 {{Fibonacci|1}} 1 {{Fibonacci|2}} 1 {{Fibonacci|3}} 2 {{Fibonacci|4}} 3 {{Fibonacci|5}} 5 {{Fibonacci|8}} 21 {{Fibonacci|10}} 55
Examples with invalid input
Code Result (returns an error message) {{Fibonacci}} Fibonacci error: Argument must be an integer {{Fibonacci|3.25}} Fibonacci error: Argument must be an integer {{Fibonacci|rabbits}} Fibonacci error: Argument must be an integer
Code
{{ifint| ( {{{1|NAN}}} ) | {{#expr: ( ( ((1 + 5^(1/2)) / 2)^( {{{1}}} ) - ((1 - 5^(1/2)) / 2)^( {{{1}}} ) ) / ( 5^(1/2) ) ) round 0 }} | {{error| Fibonacci error: Argument must be an integer }} }}
See also
- {{Fibonacci}}
- {{Lucas}}
- {{Golden ratio}} or {{phi}}