Difference between revisions of "ZCubes/Pascal Triangle and Fibonacci"

From ZCubes Wiki
Jump to navigation Jump to search
 
(5 intermediate revisions by one other user not shown)
Line 8: Line 8:
  
 
===Code - Fibonacci and Pascal Triangle===
 
===Code - Fibonacci and Pascal Triangle===
<pre>
+
m=10;
FIBONNACI(100)
+
    pt=PASCALTRIANGLE(m);
b=PASCALTRIANGLE(100)
+
    a=pt
b.map(
+
      .map(
function calcfib(r,i,d)
+
        function(r,i)
{
+
        {
var fib=0;
+
          var prefix=(REPEATCHAR(" ",(2*m-(2*i+1))/2).split(""));
var j=0;
+
            return(
for(var xi=i;xi>=0;xi--)
+
                prefix
{
+
                  .concat(r.join(", ,").split(","))
fib+=isNaN(d[xi][j])?0:d[xi][j];
+
                  .concat(prefix)
j++;
+
            )
}
+
        }
return(fib)
+
      );
}
+
  (a);
)
 
</pre>
 
  
 +
FIBONNACI(100)
  
<<[[Main_Page | About ZCubes ]]
+
b=PASCALTRIANGLE(100)
 +
b.map(
 +
    function calcfib(r,i,d)
 +
  {
 +
      var fib=0;
 +
    var j=0;
 +
          for(var xi=i;xi>=0;xi--)
 +
          {
 +
            fib+=isNaN(d[xi][j])?0:d[xi][j];
 +
          j++;
 +
                        }
 +
              return(fib)
 +
        }
 +
      )
  
 +
 +
<br/>
 +
*[[Z3 | Z3 home]]
 +
*[[Z^3 Language Documentation]]
 +
*[[ZCubes_Videos | ZCubes Videos and Tutorials]]
 +
*[[Main_Page | About ZCubes ]]
 +
<br/>
 
<br/>
 
<br/>
&copy; Copyright 1996-2020, ZCubes, Inc.
+
&copy; Copyright 1996-2021, ZCubes, Inc.

Latest revision as of 00:09, 11 March 2021

Pascal Triangle and Fibonacci


Pascal triangle can be generated easily in ZCubes. This video shows pattern of Fibonacci series using Pascal triangle using ZCubes.

Video


Pascal Triangle and Fibonacci














Code - Fibonacci and Pascal Triangle

m=10;
   pt=PASCALTRIANGLE(m);
   a=pt
      .map(
       function(r,i)
        {
         var prefix=(REPEATCHAR(" ",(2*m-(2*i+1))/2).split(""));
           return(
                prefix
                 .concat(r.join(", ,").split(","))
                 .concat(prefix)
            )
        }
     );
 (a);
FIBONNACI(100)
b=PASCALTRIANGLE(100)
b.map(
   	function calcfib(r,i,d)
  	{
      		var fib=0;
    		var j=0;
          		for(var xi=i;xi>=0;xi--)
       	   	{
        	    		fib+=isNaN(d[xi][j])?0:d[xi][j];
       	   		j++;
                       }
             		return(fib)
       }
     )





© Copyright 1996-2021, ZCubes, Inc.