Leonardo number: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: Leonardo number
| Old | New | Line | |
|---|---|---|---|
| 1 | + | # Leonardo number | |
| 2 | + | ||
| 3 | + | The Leonardo Sequence is the series of numbers: | |
| 4 | + | ||
| 5 | + | `1, 1, 3, 5, 9, 15, 25 ...` | |
| 6 | + | ||
| 7 | + | ## Recursive way | |
| 8 | + | ||
| 9 | + | ``` pascal | |
| 10 | + | function LeonardoNumber( n : integer ):integer; | |
| 11 | + | begin | |
| 12 | + | if n > 1 then result := LeonardoNumber( n - 1 ) + LeonardoNumber( n - 2 ) + 1 | |
| 13 | + | else result := 1; | |
| 14 | + | end; | |
| 15 | + | ``` | |
| 16 | + | ||
| 17 | + | ## Making use of [[Fibonacci number|Fibonacci numbers]] | |
| 18 | + | ||
| 19 | + | ``` pascal | |
| 20 | + | function LeonardoNumber2( n : integer ):integer; | |
| 21 | + | begin | |
| 22 | + | result := 2 * FibonacciNumber( n + 1) - 1 | |
| 23 | + | end; | |
| 24 | + | ``` | |
| 25 | + | ||
| 26 | + | --- | |
| 27 | + | *From the Free Pascal wiki, page "Leonardo number", as it stood on 2020-02-19 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
