shell脚本,求斐波那契数列的前10项及总和

shell脚本,求斐波那契数列的前10项及总和

cat shell
a=1
b=1
c=0
s=0
for((i=0; i<10; ++i));do
echo "$a"
let s+=a
let c=a+b
let a=b
let b=c
done
echo "sum=$s"

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/faith_girl/article/details/116025138