shell/处理用户输入/读取参数.sh

11 lines
186 B
Bash
Raw Normal View History

2016-05-13 21:42:54 +08:00
#!/bin/bash
# using one command line parameter
factorial=1
for (( number = 1; number <= $1; number++))
do
factorial=$[ $factorial * $number ]
done
echo The factor of $1 is $factorial