Lucas number/fr
Lucas number
La suite de Lucas est la suivante :
2, 1, 3, 4, 7, 11, 18, 29, 47, ...Définie comme la suite de Fibonacci mais les premiers termes sont 2 et 1.
Méthode récursive
function LucasNumber( n : integer ): integer;
begin
if n > 1 then
result := LucasNumber( n - 1 ) + LucasNumber( n - 2 )
else
if n = 0 then
result := 2
else
result := 1;
end;Emploi du nombre de Fibonacci
function LucasNumber2( n : integer ): integer;
begin
result := FibonacciNumber( n + 1 ) + FibonacciNumber( n - 1 );
end;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.