About Me

My photo

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS/E/B d-- s:++>: a-- C++(++++) UL++ P! L++ E--- W+++ N+++ w PS+ PE- !tv
b+++ G++ e++ h
------END GEEK CODE BLOCK------

Saturday, February 07, 2004

factorial shell script

#!/bin/sh
function factorial()
{
N=$1
A=1
while test $N -gt 0 ; do
A = `expr $A '*' $N`
N = `expr $N - 1`
done
echo $A
}

factorial

It is giving me a message that unary operator is expected at line 6 which is
while test $N - gt 0 ; do

No comments: