This site is supported by donations to The OEIS Foundation.

Template:Lucas/doc

From OeisWiki
Jump to: navigation, search

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

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

Usage

{{Lucas|integer}}

Valid input

An integer argument.

Examples

Examples with valid input

Code Result
{{Lucas|-5}} -11
{{Lucas|-4}} 7
{{Lucas|-3}} -4
{{Lucas|-2}} 3
{{Lucas|-1}} -1
{{Lucas|0}} 2
{{Lucas|1}} 1
{{Lucas|2}} 3
{{Lucas|3}} 4
{{Lucas|4}} 7
{{Lucas|5}} 11
{{Lucas|8}} 47
{{Lucas|10}} 123

Examples with invalid input

Code Result (returns an error message)
{{Lucas}} Lucas error: Argument must be an integer
{{Lucas|3.25}} Lucas error: Argument must be an integer
{{Lucas|rabbits}} Lucas error: Argument must be an integer

Code

{{ifint| ( {{{1|NAN}}} )
| {{#expr: ( ((1 + 5^(1/2)) / 2)^( {{{1}}} ) + ((1 - 5^(1/2)) / 2)^( {{{1}}} ) ) round 0 }}
| {{error| Lucas error: Argument must be an integer }}
}}

See also