How to resolve the algorithm Fibonacci n-step number sequences step by step in the PL/I programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Fibonacci n-step number sequences step by step in the PL/I programming language
Table of Contents
Problem Statement
These number series are an expansion of the ordinary Fibonacci sequence where: For small values of
n
{\displaystyle n}
, Greek numeric prefixes are sometimes used to individually name each series. Allied sequences can be generated where the initial values are changed:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Fibonacci n-step number sequences step by step in the PL/I programming language
Source code in the pl/i programming language
(subscriptrange, fixedoverflow, size):
n_step_Fibonacci: procedure options (main);
declare line character (100) varying;
declare (i, j, k) fixed binary;
put ('n-step Fibonacci series: Please type the initial values on one line:');
get edit (line) (L);
line = trim(line);
k = tally(line, ' ') - tally(line, ' ') + 1; /* count values */
begin;
declare (n(k), s) fixed decimal (15);
get string (line || ' ') list ( n );
if n(1) = 2 then put ('We have a Lusas series');
else put ('We have a ' || trim(k) || '-step Fibonacci series.');
put skip edit ( (trim(n(i)) do i = 1 to k) ) (a, x(1));
do j = k+1 to 20; /* In toto, generate 20 values in the series. */
s = sum(n); /* the next value in the series */
put edit (trim(s)) (x(1), a);
do i = lbound(n,1)+1 to k; /* Discard the oldest value */
n(i-1) = n(i);
end;
n(k) = s; /* and insert the new value */
end;
end;
end n_step_Fibonacci;
You may also check:How to resolve the algorithm Include a file step by step in the Scheme programming language
You may also check:How to resolve the algorithm Dragon curve step by step in the Quackery programming language
You may also check:How to resolve the algorithm Read a configuration file step by step in the Ada programming language
You may also check:How to resolve the algorithm Arithmetic/Integer step by step in the Mathematica/Wolfram Language programming language
You may also check:How to resolve the algorithm Terminal control/Dimensions step by step in the Euphoria programming language