如何在Linux中使用bash脚本处理斐波那契系列中的负面论点

问题描述

如何为bash脚本中的斐波那契数添加一个负数的条件?这是我的代码

clear
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then 
  echo "Usage: Program that finds the fibonacci series"
  echo "Options:"
  echo "-h   shows this help @R_313_4045@ion " 
  echo "-lt  the value on the left is less than the value on the right"
  echo "expr  evaluates a given expression and displays its corresponding output "
  exit 1

fi

echo 'This program will find the Fibonnacci Series'
echo "Enter the number of terms you want to be generated"
read n
f1=0
f2=1
i=2
echo "The following is the Fibonacci Series upto $n term:"
echo $f1
echo $f2
while [ $i -lt $n ]
do
  i=`expr $i + 1`
  f3=`expr $f1 + $f2
  echo $f3
  f1=$f2
  f2=$f3
done

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)