【题意】大家只要百度一下就好了吧,斐波那契数列还是那常见的呀···
#!bin/bash
bianliang=1; result1=0; result2=0; result3=0; count=0 while [ $bianliang -le 20 ] do if [ $bianliang -eq 1 ] then let result1=1 let count+=result1 let result3=result1 elif [ $bianliang -eq 2 ] then let result2=1 let count+=result2 let result3=result2 else let result3=result1+result2 let result1=result2 let result2=result3 let count+=result3 fi echo "第$bianliang个的值为:$result3" let bianliang+=1 done echo "前20项总和为:$count"