Created
January 23, 2020 23:44
-
-
Save frarteaga/16a6065f55397f6a3eb5d989ee708755 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Funcion que calcula factoriales, ejemplo: | |
# $ factorial 10 5 | |
# 10: 3628800 | |
# 5: 120 | |
function factorial() | |
{ | |
if test $# -eq "0"; then | |
# Si no hay paraametros en la linea de comandos | |
# leemos de la entrada estandar. | |
while read num; do | |
echo $num: $(echo `seq -s\* $num` | bc) | |
done | |
else | |
for num in $@; do | |
echo $num: $(seq -s\* $num | bc) | |
done | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment