28 lines
683 B
Plaintext
28 lines
683 B
Plaintext
**FREE
|
|
Ctl-Opt Main(Perform_Fibonacci_Sequence);
|
|
|
|
Dcl-Proc Perform_Fibonacci_Sequence;
|
|
|
|
Dcl-s i Uns(10);
|
|
Dcl-s fib Uns(10) Dim(10);
|
|
|
|
// Display a title
|
|
Dsply ('Fibonacci Sequence:');
|
|
|
|
// Initialize the first two elements of the array
|
|
fib(1) = 0; // The sequence usually starts with 0 and 1
|
|
fib(2) = 1;
|
|
|
|
// Loop to calculate the rest of the sequence
|
|
For i = 3 to %Elem(fib);
|
|
// Each number is the sum of the two preceding ones
|
|
fib(i) = fib(i-1) + fib(i-2);
|
|
Endfor;
|
|
|
|
// Loop to display the sequence numbers
|
|
For i = 1 to %Elem(fib);
|
|
Dsply (' ' + %Char(fib(i)));
|
|
Endfor;
|
|
|
|
End-Proc Perform_Fibonacci_Sequence;
|