RosettaCodeData/Task/Leonardo-numbers/00-TASK.txt

76 lines
3.1 KiB
Plaintext

<!-- The following <math> tag doesn't render properly as it does correctly on Wikipedia.
It generates some bold red error messages.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
:<math>
L(n) =
\begin{cases}
1 & \mbox{if } n = 0 \\
1 & \mbox{if } n = 1 \\
L(n - 1) + L(n - 2) + 1 & \mbox{if } n > 1 \\
\end{cases}
</math>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
(end of comment) -->
''Leonardo numbers'' &nbsp; are also known as the &nbsp; ''Leonardo series''.
The &nbsp; '''Leonardo numbers''' &nbsp; are a sequence of numbers defined by:
<big> L(0) = 1 [1<sup>st</sup> equation] </big>
<big> L(1) = 1 [2<sup>nd</sup> equation] </big>
<big> L(n) = L(n-1) + L(n-2) + 1 [3<sup>rd</sup> equation] </big>
─── also ───
<big> L(n) = 2 * Fib(n+1) - 1 [4<sup>th</sup> equation] </big>
:::: &nbsp; where the &nbsp; '''+ 1''' &nbsp; will herein be known as the &nbsp; ''add'' &nbsp; number.
:::: &nbsp; where the &nbsp; '''FIB''' &nbsp; is the &nbsp; [[wp:Fibonacci number|Fibonacci number]]s.
This task will be using the 3<sup>rd</sup> equation (above) to calculate the Leonardo numbers.
[[wp:Edsger W. Dijkstra|Edsger W. Dijkstra]] &nbsp; used &nbsp; Leonardo numbers &nbsp; as an integral part of
his &nbsp; [[wp:smoothsort|smoothsort]] &nbsp; [[wp:algorithm|algorithm]].
<!-- The following <math> tag doesn't render properly as it does correctly on Wikipedia:.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
:<math>1,\;1,\;3,\;5,\;9,\;15,\;25,\;41,\;67,\;109,\;177,\;287,\;465,\;753,\;1219,\;1973,\;3193,\;5167,\;8361, \ldots</math>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-->
The first few Leonardo numbers are:
''' 1 1 3 5 9 15 25 41 67 109 177 287 465 753 1219 1973 3193 5167 8361 ··· '''
;Task:
::* &nbsp; show the 1<sup>st</sup> &nbsp; '''25''' &nbsp; Leonardo numbers, starting at '''L(0)'''.
::* &nbsp; allow the first two Leonardo numbers to be specified &nbsp; [for '''L(0)''' and '''L(1)'''].
::* &nbsp; allow the &nbsp; ''add'' &nbsp; number to be specified &nbsp; ('''1''' is the default).
::* &nbsp; show the 1<sup>st</sup> &nbsp; '''25''' &nbsp; Leonardo numbers, specifying '''0''' and '''1''' for '''L(0)''' and '''L(1)''', and '''0''' for the ''add'' number.
(The last task requirement will produce the Fibonacci numbers.)
Show all output here on this page.
;Related tasks:
* &nbsp; [[Fibonacci number]]
* &nbsp; [[Fibonacci n-step number sequences ]]
;See also:
* &nbsp; [[wp:Leonardo number|Wikipedia, Leonardo numbers]]
* &nbsp; [[wp:Fibonacci number|Wikipedia, Fibonacci numbers]]
* &nbsp; [[oeis:A001595|OEIS Leonardo numbers]]
<br><br>