F How can we find Fibonacci Series using javascript ? | CodeTheta

How can we find Fibonacci Series using javascript ?



Here is a simple javascript program that related to Fibonacci series.This is a simple program which is written in javascript program

Attention: Write this code and save it to .html extension and when you run this code through your browser always choose internet explorer to test the code because in upper version of Firefox browser it will not work and i have not tested it through chrome browser.

when you run it through internet explorer in browser you will see the "fibonacci series" click on that and after that a popup will appear and says "Enter Number" , type what you want and then click ok and after that you will see that calculated Fibonacci Series number


<html>
<script language="JavaScript"> 
function f()
{
 var a,b,c,n;
 n=parseInt(prompt("Enter Number"));
 a=0;
 b=1;
 document.write(a);
 document.write(b);
 for(i=3; i<=n; i++)
 {
   c=(a+b);
   document.write(c);
   a=b;
   b=c;
 }
}
</script>
<body>
<a href="" onClick="f()">fibonacci series</a>
</body>
</html>
Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us

Post a Comment