fibo() { if(( $1==1 )) then echo 0 elif (( $1==2 )) then echo 1 else (( t=$1-1 )) a=`fibo $t` (( t=$1-2 )) b=`fibo $t` (( res=a+b )) echo $res fi } echo -e "Enter an integer: \c" read n if(( n>0 )) then for(( i=1;i<=n;i++ )) do echo -e "`fibo $i` \c" done echo else echo ERROR: Invalid input given fi
No comments:
Post a Comment