W.A.S.S to generate the series 1 + x + x2 + x3 + …. + xn.
Program
# W.A.S.S to generate the series 1 + x + x2 + x3 + …. + xn.
echo "Enter value of X:"
read x
echo "Enter value of n:"
read n
sum=1
temp=1;
while test $n -gt 0
do
temp=`expr $x^$n | bc` #bc - An arbitrary precision calculator
sum=`expr $sum + $temp`
n=`expr $n - 1`
done
echo "Result=$sum"
Output
Enter value of X:
6
Enter value of n:
4
Result=1555