Goodiny777

Fibonacci numbers with recurcy method

Nov 29th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <title>Page Title</title>
  5.         <script>
  6.             var stringToPrint="";
  7.             function fibonacci(x,y)
  8.             {
  9.                if(y<=getValue.value){stringToPrint+=x+", "; fibonacci(y,x+y);}
  10.                else stringToPrint+=x;
  11.                res.innerHTML=stringToPrint;
  12.             }
  13.             function multiplyClicks()
  14.             {
  15.                 stringToPrint="";
  16.                 fibonacci(1,1);
  17.                 var tempArr=stringToPrint.split(", ");                                      
  18.                 for(var counter=0;counter<tempArr.length;counter+=1)
  19.                    if(tempArr[counter]==getValue.value)
  20.                     found.innerHTML="Your number appears";
  21.                    else
  22.                     found.innerHTML="Your number doesn't appear";
  23.            }      
  24.         </script>
  25.     </head>
  26.     <body>
  27.         Fibonacci numbers from 1 to your number<br/>
  28.         <input type="number", id="getValue"/><br />
  29.         <input type="button", value="Get Fibbonacci", onclick="multiplyClicks()"/><hr />
  30.         <div id="res"></div>
  31.         <div id="found"></div>
  32.     </body>
  33. </html>
Advertisement
Add Comment
Please, Sign In to add comment