Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Fibonacci script

I have this Fibonacci script

#!/bin/bash
if (test $# -ne 1) then
 echo "Use: 0ドル number"
exit 1 fi
for c in ‘seq 1 1ドル‘
do
 if (($c == 1))
 then
n0=1;
 echo "fibonacci(1)=$n0";
 elif (($c == 2));
 then
n1=1;
 echo "fibonacci(2)=$n1";
 else
 n=$(($n0+$n1));
 echo "fibonacci($c)=$n";
 n0=$n1;
 n1=$n;
fi done
type here

I have to made a substitution of the expression evaluation $(($n0+$n1))with the shell command expr $n0 + $n1.

I Rembember that to assign the output of a command to a varible i have to made command > output.txt but I don’t know how to apply it on this exercise. Thank you so much for your help.

Answer*

Draft saved
Draft discarded
Cancel
1
  • Thank you su much , especially Thank you for explaining to me the correct use of this instruction. I wrote wrongly n = expr ( $n0 + $n1 ) Commented Oct 21, 2024 at 14:15

lang-bash

AltStyle によって変換されたページ (->オリジナル) /