Hello Guys,For my homework I must write a shell script to do this serie,
I know that I must use the "bc" for that, but for the script's itself i have no idea,(beginner)
Can you plz just help me for have some idea?
Thanks
I wrote a script but it did not worked
#!/bin/sh
echo "Input number"
read n
counter=0
ans=1
while [ $counter -ne $n ]
do
ans=`expr 4*(-1/(2*$counter+1))`| bc -l
counter=`expr counter+1`
done
echo "the sum of the series is :-$ans"
I know that I must use the "bc" for that, but for the script's itself i have no idea,(beginner)
Can you plz just help me for have some idea?
Thanks
I wrote a script but it did not worked
#!/bin/sh
echo "Input number"
read n
counter=0
ans=1
while [ $counter -ne $n ]
do
ans=`expr 4*(-1/(2*$counter+1))`| bc -l
counter=`expr counter+1`
done
echo "the sum of the series is :-$ans"