Leonardo number/fr: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 1 | # Nombre de Léonard | |
| 2 | 2 | ||
| 3 | 3 | La suite de Léonard est la suivante : | |
| 4 | 4 | ||
| 5 | - | ||
| 5 | + | ```text | |
| 6 | + | 1, 1, 3, 5, 9, 15, 25 ... | |
| 7 | + | ``` | |
| 6 | 8 | ||
| 7 | 9 | Chaque est la somme de ses prédécesseurs + 1, les premiers termes sont 1 et 1. | |
| 8 | 10 | ||
| 9 | 11 | ## Méthode récursive | |
| 10 | 12 | ||
| 11 | 13 | ``` pascal | |
| 12 | 14 | function LeonardoNumber( n : integer ):integer; | |
| 13 | 15 | begin | |
| 14 | 16 | if n > 1 then result := LeonardoNumber( n - 1 ) + LeonardoNumber( n - 2 ) + 1 | |
| 15 | 17 | else result := 1; | |
| 16 | 18 | end; | |
| 17 | 19 | ``` | |
| 18 | 20 | ||
| 19 | 21 | ## Emploi du [[Fibonacci number/fr|nombre de Fibonacci]] | |
| 20 | 22 | ||
| 21 | 23 | ``` pascal | |
| 22 | 24 | function LeonardoNumber2( n : integer ):integer; | |
| 23 | 25 | begin | |
| 24 | 26 | result := 2 * FibonacciNumber( n + 1) - 1 | |
| 25 | 27 | end; | |
| 26 | 28 | ``` | |
| 27 | 29 | ||
| 28 | 30 | --- | |
| 29 | 31 | *From the Free Pascal wiki, page "Leonardo number/fr", 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).* |
