write a javascript program to find n number of fibonacci series.

In this JavaScript tutorial we are learning about fibonacci series.

fibonacci series

Fibonacci number series are those numbers whose first two numbers are the sum of third numbers. 

Fro example 

1, 1, 2, 3, 5

In this above example , the first two number of the series are the sum of the third number, like 1+1=2 ,in the above series the sum first number 1 and second number 1 is third number that is 2 , or the sum of  third number that is 2 and forth that is 3 is 5.


write a javascript program to find n number of fibonacci series.


<html>

<head>

    <title>fibonacci series</title>

    </head>

    <body>

    <script type="text/javascript">

        

        var limit=prompt("enter the limit 'n' to generate fibonacci series;"," ");

        var f1=0;

        var f2=1;

        

        document.write("the limit enter to generate fibonacci series",limit,"<br/>");

        document.write("the fibonacci series < ");

        document.write(" ",f1," ");

        document.write(" ",f2," ");

        

        var i,f3;

        for(i=2;i<=limit;i++)

            {

                f3=f1+f2;

                f1=f2;

                f2=f3;

            }

        </script>

    </body>

</html>

output:

write a javascript program to find n number of fibonacci series.


write a javascript program to find n number of fibonacci series.














Post a Comment

0 Comments