Advertisement
Sax

Fibonacci en Javascript

Sax
May 18th, 2011
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2. var impreso0=0;
  3. var impreso1=1;
  4. var impreso2;
  5. var i;
  6. a = prompt("Cuantos dígitos quieres del fibonacci?");
  7.  
  8. document.write(impreso0+"<br />");
  9. document.write(impreso1+"<br />");
  10.  
  11. for(i=3;i<=a;i++){
  12. impreso2=impreso0+impreso1;
  13. impreso0=impreso1;
  14. impreso1=impreso2;
  15. document.write(impreso2+"<br />");
  16. }
  17. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement