In shell scripting how to find factorial of a number?
10! in bash:
f=1; for k in {1..10}; do f=$[$k * $f] ; done; echo $f
or here in a step by step fashion:
$ t=$(echo {1..10}) $ echo $t 1 2 3 4 5 6 7 8 9 10 $ t=${t// /*} $ echo $t 1*2*3*4*5*6*7*8*9*10 $ echo $[$t] 3628800