<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title> 求1,1,2,3,5,8,13,21,34,...... 的第N 位結果</title>
</head>
<%
'================= ================== =======
' 求1,1,2,3,5,8,13,21,34,...... 的第N 位結果
' 遞迴方法
'================= ================== =======
on error resume next
Server.ScriptTimeOut=999999 '' 處理資料可能需要長時間
a=trim(request("t1"))
if a="" then
response.Write("Please input number in textbox")
else
Response.Write(" 第"+a+" 位的結果是:")
Response.Write(foo(cint(a)))
end if
'递归函数求第N位结果
function foo(a)
if a<=0 then
foo=0
elseif a=1 or a=2 then
foo=1
else
foo=foo(a-1)+foo(a-2)
end if
end function
%>
<form name="form1" method="post" action="">
<input name="t1" type="text" id="t1" size="20">
<input type="submit" name="Submit" FONT-FAMILY: 'PMingLiU','serif'; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">提交">
</form>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>
</head>
<%
'=================
'
'
'=================
on error resume next
Server.ScriptTimeOut=999999 ''
a=trim(request("t1"))
if a="" then
response.Write("Please input number in textbox")
else
Response.Write("
Response.Write(foo(cint(a)))
end if
'递归函数求第N位结果
function foo(a)
if a<=0 then
foo=0
elseif a=1 or a=2 then
foo=1
else
foo=foo(a-1)+foo(a-2)
end if
end function
%>
<form name="form1" method="post" action="">
<input name="t1" type="text" id="t1" size="20">
<input type="submit" name="Submit" FONT-FAMILY: 'PMingLiU','serif'; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">提交">
</form>