Lucas 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 | # Lucas number | |
| 2 | 2 | ||
| 3 | 3 | La suite de Lucas est la suivante : | |
| 4 | 4 | ||
| 5 | - | ||
| 5 | + | ```text | |
| 6 | + | 2, 1, 3, 4, 7, 11, 18, 29, 47, ... | |
| 7 | + | ``` | |
| 6 | 8 | ||
| 7 | 9 | Définie comme la [[Fibonacci number/fr|suite de Fibonacci]] mais les premiers termes sont 2 et 1. | |
| 8 | 10 | ||
| 9 | 11 | ## Méthode récursive | |
| 10 | 12 | ||
| 11 | 13 | ``` pascal | |
| 12 | 14 | ||
| 13 | 15 | function LucasNumber( n : integer ): integer; | |
| 14 | 16 | begin | |
| 15 | 17 | if n > 1 then | |
| 16 | 18 | result := LucasNumber( n - 1 ) + LucasNumber( n - 2 ) | |
| 17 | 19 | else | |
| 18 | 20 | if n = 0 then | |
| 19 | 21 | result := 2 | |
| 20 | 22 | else | |
| 21 | 23 | result := 1; | |
| 22 | 24 | end; | |
| 23 | 25 | ``` | |
| 24 | 26 | ||
| 25 | 27 | ## Emploi du [[Fibonacci number/fr|nombre de Fibonacci]] | |
| 26 | 28 | ||
| 27 | 29 | ``` pascal | |
| 28 | 30 | ||
| 29 | 31 | function LucasNumber2( n : integer ): integer; | |
| 30 | 32 | begin | |
| 31 | 33 | result := FibonacciNumber( n + 1 ) + FibonacciNumber( n - 1 ); | |
| 32 | 34 | end; | |
| 33 | 35 | ``` | |
| 34 | 36 | ||
| 35 | 37 | --- | |
| 36 | 38 | *From the Free Pascal wiki, page "Lucas 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).* |
