Kode skal ændres til asp kode
Er der nogen der kan konvertere denne web aplication til asp kode så den kan køre som en ganske almindelig asp kode?-----------------------------------------------------------
x=0
y=0
m=1
params=`echo $QUERY_STRING | tr '&' ' '`
for param in $params
do
case $param in
x=*) x=`echo $param | sed 's/^x=//'` ;;
y=*) y=`echo $param | sed 's/^y=//'` ;;
m=*) m=`echo $param | sed 's/^m=//'` ;;
esac
done
export BC_LINE_LENGTH=2147483647
# use bc for arbitrary precision
n=`bc -q << EOF
x=$x
y=$y
m=$m
if (x < 0)
halt
if (y < 0)
halt
if (m < 2)
halt
n=1; /* we multiply this by stuff and eventually return it */
a=x; /* x^(2^j) */
b=y; /* we divide this by 2 and look at the last bit repeatedly */
while (b > 0)
{
/* if this bit is set in the binary representation */
if (b % 2 == 1)
n = (n * a) % m;
a = (a * a) % m;
b /= 2;
}
print n
quit
EOF
2>&1`
echo -n -e "Content-Type: text/html; charset=utf-8\r\n\r\n"
cat <<EOF
<html lang="en" xml:lang="en">
<head>
<title>Modulo M Calculator</title>
<style type="text/css">
sup { vertical-align: top; font-size: 60%; }
</style>
</head>
<body>
<h1>Modulo M Calculator</h1>
<h2>calculates x<sup>y</sup> mod m</h2>
<form action="$SCRIPT_NAME" method="get">
<p><big>x = <input type="text" name="x"/></big></p>
<p><big>y = <input type="text" name="y"/></big></p>
<p><big>m = <input type="text" name="m"/></big></p>
<p><input type="submit" value="calculate"/></p>
</form>
EOF
if [ "X$n" != "X" ]
then
echo "<hr/>"
echo "<h2>the answer is $n</h2>"
echo "<p><big>$x<sup>$y</sup> ≡ $n mod $m</big></p>"
echo "<p>for the impaired browser: <tt>$x^$y = $n mod $m</tt></p>"
elif [ "X$QUERY_STRING" != "X" ]
then
echo "<hr/>"
echo "<p>invalid input</p>"
fi
echo "<hr/>"
echo "</body>"
echo "</html>"
