0
1.0kviews
Write a simple JavaScript example program for Fibonacci Sequence.
1 Answer
written 6.3 years ago by | • modified 6.2 years ago |
Program :
<!DOCTYPE html>
<html>
<header><title>Fibonacci Series</title></header>
<body>
<h3>Fibonacci Series</h3>
<script type="text/javascript">
var a=0,b=1;
document.write(a+"<br/>"+b+"<br/>");
var n=10;
for(var i=1;i<=n-2;i++)
{
var c=a+b;
document.write(c);
document.write("<br/>");
a=b;
b=c;
}
</script>
</body>
</html>