FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 766   



Demo

Code

<html>

<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script>
        $(document).ready(function() {
            $("#btn").click(function() {
                var first_number = 0;
                var second_number = 1;

                var size = $("#number").val();
                result = $("#result");
                var output = '0,1';

                for (i = 0; i < size - 2; i++) {
                    var next_number = first_number + second_number;
                    output = (output + (",") + next_number);
                    first_number = second_number;
                    second_number = next_number;
                }
                $("#result").html(output);
            });
        });
    </script>
</head>

<body>
    Enter the number of items in fibonacci series:
    <input type="text" name="value" id="number"></input>
    <button id="btn"> Submit </button><br>
    <h4>Output: <br> <span id="result"></span></h4>
</body>

</html>



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News