-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fibonacci.html
53 lines (51 loc) · 1.56 KB
/
Fibonacci.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Fibonacci Series</title>
<script type="text/javascript">
function getSeries()
{
var startNum = parseInt(document.getElementById("sNum").value);
var limit = parseInt(document.getElementById("eNum").value);
var field = document.getElementById("series");
field.innerHTML = "";
if(!isNaN(startNum) && !isNaN(limit))
{
for(var i = startNum; i <= limit+startNum; i++ )
{
field.innerHTML += generateSeries(i) + "<br/>";
}
}
else
{
field.innerHTML = "Please Provide Only Numbers in The Fields.....";
}
}
function generateSeries(num)
{
var a = 0,b=1;
for(var i = 0; i < num-1; i++ )
{
var temp = a;
a = b;
b += temp;
}
return a;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<strong>Enter The First Number Of Series :</strong>
<input type="text" id="sNum" /><br />
<strong>Enter The Limit :</strong>
<input type="text" id="eNum" /><br />
<button type="submit" onclick="getSeries();return false">
<strong>Generate The Series</strong></button>
<p id="series">
</p>
</div>
</form>
</body>
</html>