Code:
<!DOCTYPE html>
<html>
<body>
<center><h1>Fibonacci Numbers in your Range</h1>
<script>
var fib1=0,fib2=1,fib3=0;
var nl="<br>";
var lower=parseInt(prompt("Enter lower limit"));
var upper=parseInt(prompt("Enter upper limit"));
for(var i=lower;i<upper;i++)
{
if (fib3<=upper)
{
if (fib3>=lower)
{
document.write(fib3+nl);
}
fib1=fib2;
fib2=fib3;
fib3=fib1+fib2;
}
}
</script>
</center>
</body>
</html>
No comments:
Post a Comment