Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- </head>
- <body>
- <input id="input" type="number" max="1000" title="please enter number only">
- <button value="submit" onclick="fibonaci()">submit</button>
- </body>
- <script>
- var count = 0;
- var a = 0, b = 1, c = 0;
- function fibonaci(){
- var n = document.getElementById("input").value;
- if(n >= 1 && n <= 100)
- {
- while(count < n)
- {
- c = a + b;
- console.log(c);
- a = b;
- b = c;
- count ++;
- }
- }
- }
- </script>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement