Fibonacci Sequence

While I was doing quickie problems, I saw someone was asked to show a sample of the Fibonacci Sequence.  This one only took about 3 minutes.  Simple math.

You can sum up the problem as a+b=c, b+c=d, c+d=e, etc for infinity.  For mine, I stopped at 2 million whatever.


var x=0; y=1;
while (x<1000000) {
  var z = x+y;
  x = y; y = z;
  document.write(z + "<br>");
}

Like I said.  Simple math.  You can look at my CodePen and adjust the while loop to make it go higher, if you like.

Leave a Reply

Your email address will not be published. Required fields are marked *