Home > OS >  Under Linux using shell script
Under Linux using shell script

Time:10-24

Under Linux using shell script using an array of the Fibonacci sequence before 20 items and combined, and the great god help how to write a program
Thank you very much!

CodePudding user response:

Wrote a casually, can consult
 #!/bin/bash 
A=0
B=1
Fibo=(0, 1)
Sum=1
Echo "fibo list 1:" $a
Echo "fibo list 2:" $b
For ((I=3; i<=20; i++));
Do
Let a + c=$$b;
A=$b;
B=$c;
Fibo=(${fibo (@)} $c);
Let d=$I - 1;
Echo "fibo list" $I ":" ${fibo [$d]}.
Let the sum=$sum + ${fibo [$d]}.
The done
Echo "fibo 20 sum is:" $sum
  • Related