%@ LANGUAGE = PerlScript%>
Fibonacci numbers through 17
Date/time: <%
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime();
$thisday=(Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday)[$wday];
$thismon=(January,February,March,April,May,June,July,August,September,October,November,December)[$mon];
$time = sprintf '%2.2d:%2.2d:%2.2d',$hour,$min,$sec;
$year += 1900;
$datetime = $thisday.', '.$thismon.' '.$mday.', '.$year.' '.$time;
$Response->write($datetime);
%>
<%$N = 17;%>
Fibonacci numbers through <%= $N %>
Computations done via function calls
<%for ($i = 0; $i<$N; $i++){%>
<%=$i%> |
<%$Response->write(&Fibonacci($i));%> |
<%}%>
<%sub Fibonacci
{
local $i=$_[0];
local $fibA = 1;
local $fibB = 1;
if ($i == 0)
{
return $fibA;
}
elsif ($i == 1)
{
return $fibB;
}
elsif ($i > 1)
{
for ($j = 2; $j<=$i; $j++)
{
$fib = $fibA + $fibB ;
$fibA = $fibB ;
$fibB = $fib;
}
return $fib;
}
} %>
<%
$url = $Request->ServerVariables('PATH_INFO')->item;
$_ = $Request->ServerVariables('PATH_TRANSLATED')->item;
s/[\/\\](\w*\.asp\Z)//m;
$params = 'filename='."$1".'&URL='."$url";
$params =~ s#([^a-zA-Z0-9&_.:%/-\\]{1})#uc '%' . unpack('H2', $1)#eg;
%>
Return
view the source