shell腳本之斐波那契數列

  1 #!/bin/bash                                                                 
  2 
  3 #fibo 0,1,1,2,3,5,8,13
  4 
  5 echo 0 > file
  6 echo 1 >> file
  7 
  8 count=$1
  9 
 10 for i in `seq $count`
 11 do
 12     first=$(tail -2 file | head -1)
 13     two=$(tail -1 file)
 14     echo $((first+two)) >> file
 15 done
 16 cat file
 17 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章