Sign in Join
Wiki copytemporary

Leonardo number/ru: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: Leonardo number/ru

OldNewLine
1+# Числа Leonardo
2+
3+Числа Leonardo задаются следующей последовательностью:
4+
5+`1, 1, 3, 5, 9, 15, 25 ...`
6+
7+## Рекурсивный способ
8+
9+``` pascal
10+function LeonardoNumber( n : integer ):integer;
11+begin
12+ if n > 1 then result := LeonardoNumber( n - 1 ) + LeonardoNumber( n - 2 ) + 1
13+ else result := 1;
14+end;
15+```
16+
17+## Вычисление с помощью [[Fibonacci number/ru|чисел Fibonacci]]
18+
19+``` pascal
20+function LeonardoNumber2( n : integer ):integer;
21+begin
22+ result := 2 * FibonacciNumber( n + 1) - 1
23+end;
24+```
25+
26+---
27+*From the Free Pascal wiki, page "Leonardo number/ru", 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).*

Back to history