Fibonacci Series

08/10/2009 01:55

<html>
<head>
<title>Program for Fibbonacci series</title>
</head>
<body>
<!Write javascript program to enter any number and find the fibonacci series>
<! Roll no=15>
<script language="javascript">
var prev=0,cur=1,next,cnt;
 num1=parseInt(prompt("enter number1",""));
document.write(prev+"<br>");
document.write(cur+"<br>");
for(cnt=3;cnt<=num1;cnt++)
{
next=prev+cur;
document.write(next+"<br>");
prev=cur;
cur=next;
}
</script>
</body>
</html>

Back

Search site

Copyright © 2012 Dadaso Zanzane. All rights reserved.