Leonardo number
Deutsch · English · Français · Suomi · Русский
Leonardo number
The Leonardo Sequence is the series of numbers:
1, 1, 3, 5, 9, 15, 25 ...
Recursive way
function LeonardoNumber( n : integer ):integer;
begin
if n > 1 then result := LeonardoNumber( n - 1 ) + LeonardoNumber( n - 2 ) + 1
else result := 1;
end;Making use of Fibonacci numbers
function LeonardoNumber2( n : integer ):integer;
begin
result := 2 * FibonacciNumber( n + 1) - 1
end;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.
Talk about this page
Nobody has opened a bench for this page yet. Sign in to open one.
