Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,7 @@
factorial() {
set -- "$1" 1
until test "$1" -lt 2; do
set -- "`expr "$1" - 1`" "`expr "$2" \* "$1"`"
done
echo "$2"
}

View file

@ -0,0 +1,7 @@
function factorial {
typeset n=$1 f=1 i
for ((i=2; i < n; i++)); do
(( f *= i ))
done
echo $f
}

View file

@ -0,0 +1,7 @@
factorial ()
{
if [ $1 -eq 0 ]
then echo 1
else echo $(($1 * $(factorial $(($1-1)) ) ))
fi
}

View file

@ -0,0 +1,5 @@
function factorial {
typeset n=$1
(( n < 2 )) && echo 1 && return
echo $(( n * $(factorial $((n-1))) ))
}

View file

@ -0,0 +1,10 @@
factorial()
{
if [ $1 -le 1 ]
then
echo 1
else
result=$(factorial $[$1-1])
echo $((result*$1))
fi
}