Fibonacci series in JavaScript


Write a program to accept a no. and print Fibonacci series upto that terms.



How many numbers :


<HTML>
<HEAD>



<TITLE>Fibonacci series by Kashid</TITLE>
<script>
function display()
 {
  var n=parseInt(frm.t1.value)
  var a=0,b=1,c=0,s=" ";
//  document.write("Fibonacci Series: ")
  while((a+b)<=n)
      {
         c=a+b;
         //document.write(c+" ");
         s=s+c+ " , ";
         b=a;
         a=c;
      
       }

alert("Fibonacci Series: "+s)
 }
</script>
</HEAD>
<BODY>
<form name=frm>
  <input type=text name=t1>
  <input type=button name=b1 onclick="display();" value="fibonacci series">
  </form>

</BODY>
</HTML>

4 comments:

  1. I don't Know Programming but you have written good information for Free!

    ReplyDelete
  2. ok good..

    http://northluzonrealty.blogspot.com/

    ReplyDelete
  3. Very useful, but i also found a blog http://rindovincent.blogspot.com where there is also simple fibonacci program for beginners. Hope it will be helpful for beginners

    ReplyDelete

Thanks for visiting my Blog!

Have a Question ? Need Help in College Assignments, Need Code that is not available here? Just leave a comment & get your code instantly.

Tips to Enhance Your Blog