Search
 
SCRIPT & CODE EXAMPLE
 

HTML

Fibonacci Series in html

<html>
    <head>
        <script>
          function fib(number) {

    var loop = [0, 1];

    for (var i = 2; i < number; i++) {
        loop[i] = loop[i-1]+ loop[i-2];


    return loop[number-1];
    }

            document.getElementById("output").innerHTML
    }
        </script>

    </head>
    <body>
        <input type text="text" id="txtloop" />
        <input type="button" id="btnEnter" value="Enter" onclick="fib(txtloop.value)" />

        <p id="output"></p>

    </body>
</html>
Comment

Fibonacci Series in html

<html>
<body>

 <input type text="text" id="txtloop" />
        <input type="button" id="btnEnter" value="Enter" onclick="fibonacci_series(txtloop.value)" />

        <p id="output"></p>
<p id="demo"></p>

<script>
var fibonacci_series = function (n) 
{
  if (n==1) 
  {
var loop = [0, 1];
   document.getElementById("output").innerHTML = loop;
  return loop;
  } 
  else 
  {
    var s = fibonacci_series(n - 1);
    s.push(s[s.length - 1] + s[s.length - 2]);
    document.getElementById("output").innerHTML =s;
    return s;
  }
   
};

</script>

</body>
</html>
 Run code snippet
Comment

PREVIOUS NEXT
Code Example
Html :: print button html 
Html :: block level elements 
Html :: write python code in html 
Html :: html min value 
Html :: html date placeholder 
Html :: range input html 
Html :: address tag in html 
Html :: html pallete 
Html :: css stick div to bottom of page 
Html :: target vs currenttarget 
Html :: image as banner html 
Html :: edit button html 
Html :: input number maxlength html 
Html :: bootstrap modal causes page shift 
Html :: theme color in html 
Html :: limit number of values in a twxt input 
Html :: html images 
Html :: form.html 
Html :: use variable in input value vuejs 
Html :: bootstrap + cards 
Html :: center text in html 
Html :: links in html 
Html :: ionic format date 
Html :: meta for author 
Html :: progress-bar-success bootstrap 4 
Html :: how to add bg html 
Html :: collapse bootsrap 
Html :: use jquery variable in html 
Html :: how to set a date for type date inpt 
Html :: lxml.html get element by id 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =