Difference between revisions of "Leonardo number/fi"
From Free Pascal wiki
Jump to navigationJump to search (Created page with "{{Leonardo_number}} = Leonardon numero = Leonardon sarja on seuraavanlainen numerosarja: 1, 1, 3, 5, 9, 15, 25 ... == Leonardon numero rekursiivinen tavalla == <syntaxh...") |
|||
Line 8: | Line 8: | ||
− | == Leonardon numero | + | == Leonardon numero rekursiivisellä tavalla == |
<syntaxhighlight> | <syntaxhighlight> | ||
Line 19: | Line 19: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
== Leonardon numero käyttämällä [[Fibonacci number/fi|Fibonacin numeroa]] == | == Leonardon numero käyttämällä [[Fibonacci number/fi|Fibonacin numeroa]] == |
Revision as of 18:04, 21 October 2018
│
Deutsch (de) │
English (en) │
suomi (fi) │
français (fr) │
русский (ru) │
Leonardon numero
Leonardon sarja on seuraavanlainen numerosarja:
1, 1, 3, 5, 9, 15, 25 ...
Leonardon numero rekursiivisellä tavalla
function LeonardoNumber( n : integer ):integer;
begin
if n > 1 then result := LeonardoNumber( n - 1 ) + LeonardoNumber( n - 2 ) + 1
else result := 1;
end;
Leonardon numero käyttämällä Fibonacin numeroa
function LeonardoNumber2( n : integer ):integer;
begin
result := 2 * FibonacciNumber( n + 1) - 1
end;