This site is supported by donations to The OEIS Foundation.

Template:Fibonacci/doc

From OeisWiki
Jump to: navigation, search

This documentation subpage contains instructions, categories, or other information for Template:Fibonacci. [<Edit> Template:Fibonacci]

[⧼Purge⧽ Template:Fibonacci/doc]
The {{Fibonacci}} mathematical function template returns the
n
th Fibonacci number, where
n
is an integer. It uses Binet’s closed-form formula for the Fibonacci numbers.

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