How to resolve the algorithm Fibonacci word step by step in the zkl programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Fibonacci word step by step in the zkl 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 zkl programming language

Source code in the zkl programming language

fcn entropy(bs){ //binary String-->Float
   len:=bs.len(); num1s:=(bs-"0").len();
   T(num1s,len-num1s).filter().apply('wrap(p){ p=p.toFloat()/len; -p*p.log() })
   .sum(0.0) / (2.0).log();
}

"  N     Length      Entropy Fibword".println();
ws:=L("1","0");
foreach n in ([1..37]){
   if(n>2) ws.append(ws[-1]+ws[-2]);
   w:=ws[-1];
   "%3d %10d %2.10f %s".fmt(n,w.len(),entropy(w),
      w.len()<50 and w or "").println();
}

  

You may also check:How to resolve the algorithm Kronecker product step by step in the Octave programming language
You may also check:How to resolve the algorithm User input/Text step by step in the HolyC programming language
You may also check:How to resolve the algorithm Loops/Downward for step by step in the Ursa programming language
You may also check:How to resolve the algorithm Caesar cipher step by step in the Delphi programming language
You may also check:How to resolve the algorithm Abundant, deficient and perfect number classifications step by step in the TypeScript programming language