How to resolve the algorithm Fibonacci word step by step in the PL/I programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Fibonacci word step by step in the PL/I programming language

Table of Contents

Problem Statement

The   Fibonacci Word   may be created in a manner analogous to the   Fibonacci Sequence   as described here:

Perform the above steps for     n = 37. You may display the first few but not the larger values of   n. {Doing so will get the task's author into trouble with them what be (again!).} Instead, create a table for   F_Words   1   to   37   which shows:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Fibonacci word step by step in the PL/I programming language

Source code in the pl/i programming language

fibword: procedure options (main);  /* 9 October 2013 */
   declare (fn, fnp1, fibword) bit (32000) varying;
   declare (i, ln, lnp1, lfibword) fixed binary(31);

   fn = '1'b; fnp1 = '0'b; ln, lnp1 = 1;
   put skip edit (1, length(fn), fn)     (f(2), f(10), x(1), b);
   put skip edit (2, length(fnp1), fnp1) (f(2), f(10), x(1), b);
   do i = 3 to 37;
      lfibword = lnp1 + ln;
      ln = lnp1;
      lnp1 = lfibword;
      if i <= 10 then
         do;
            fibword = fnp1 || fn;
            put skip edit (i, length(fibword), fibword) (f(2), f(10), x(1), b);
            fn = fnp1; fnp1 = fibword;
         end;
      else
         do;
            put skip edit (i, lfibword) (f(2), f(10));
         end;
   end;

end fibword;

  

You may also check:How to resolve the algorithm Averages/Mean angle step by step in the PL/I programming language
You may also check:How to resolve the algorithm Sorting algorithms/Shell sort step by step in the PL/I programming language
You may also check:How to resolve the algorithm Tau function step by step in the PL/I programming language
You may also check:How to resolve the algorithm Doubly-linked list/Traversal step by step in the PL/I programming language
You may also check:How to resolve the algorithm Formatted numeric output step by step in the PL/I programming language