How do you find the factorial of a number in a Bash script?

前端 未结 13 2084
别那么骄傲
别那么骄傲 2021-02-14 03:24

In shell scripting how to find factorial of a number?

13条回答
  •  难免孤独
    2021-02-14 04:07

    echo Enter Number
    
    read num
    fact=1
    for ((i=1;i<=num;i++))
    do
    fact=$(($fact*$i))
    done
    echo $fact
    

提交回复
热议问题