shell脚本之计算n的阶乘

匿名 (未验证) 提交于 2019-12-03 00:21:02
#!/bin/bash  while true do     read -p "please input a number to compute jiecheng: " number     (($number+0)) >/dev/null     if (($? != 0))     then         echo "input error,please input again!"         continue      fi     if (($number <= 0))     then         echo "input number must bigger than 0!please input again!"         continue      fi     sum=1      for i in `seq 1 $number`      do         sum=$((sum*i))     done     echo "${number}! = $sum"  done

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!