How to resolve the algorithm Leonardo numbers step by step in the PureBasic programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Leonardo numbers step by step in the PureBasic programming language
Table of Contents
Problem Statement
Leonardo numbers are also known as the Leonardo series.
The Leonardo numbers are a sequence of numbers defined by:
This task will be using the 3rd equation (above) to calculate the Leonardo numbers.
Edsger W. Dijkstra used Leonardo numbers as an integral part of his smoothsort algorithm.
The first few Leonardo numbers are:
(The last task requirement will produce the Fibonacci numbers.)
Show all output here on this page.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Leonardo numbers step by step in the PureBasic programming language
Source code in the purebasic programming language
EnableExplicit
#N = 25
Procedure leon_R(a.i, b.i, s.i = 1, n.i = #N)
If n>2
Print(Space(1) + Str(a + b + s))
ProcedureReturn leon_R(b, a + b + s, s, n-1)
EndIf
EndProcedure
If OpenConsole()
Define r$
Print("Enter first two Leonardo numbers and increment step (separated by space) : ")
r$ = Input()
PrintN("First " + Str(#N) + " Leonardo numbers : ")
Print(StringField(r$, 1, Chr(32)) + Space(1) +
StringField(r$, 2, Chr(32)))
leon_R(Val(StringField(r$, 1, Chr(32))),
Val(StringField(r$, 2, Chr(32))),
Val(StringField(r$, 3, Chr(32))))
r$ = Input()
EndIf
You may also check:How to resolve the algorithm Bitwise operations step by step in the MATLAB / Octave programming language
You may also check:How to resolve the algorithm Call an object method step by step in the Objeck programming language
You may also check:How to resolve the algorithm Bitmap step by step in the Oz programming language
You may also check:How to resolve the algorithm String interpolation (included) step by step in the UNIX Shell programming language
You may also check:How to resolve the algorithm Unicode strings step by step in the Ring programming language