Shell script to generate the series 1+x + x2+ x3+….+xn, Programming Languages

 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

Posted Date: 9/26/2012 4:42:14 AM | Location : United States







Related Discussions:- Shell script to generate the series 1+x + x2+ x3+….+xn, Assignment Help, Ask Question on Shell script to generate the series 1+x + x2+ x3+….+xn, Get Answer, Expert's Help, Shell script to generate the series 1+x + x2+ x3+….+xn Discussions

Write discussion on Shell script to generate the series 1+x + x2+ x3+….+xn
Your posts are moderated
Related Questions
I need an application that will gather data from one SQL Database and update another. Data is contained in dbo.CallList with following fields: Customer_ID, AlreadyPickedUp, Phone_N


how do I change a existing formula with a new formula and it show the result

Write a program to calculate amount after n number of years by inputting principal at the rate of 8% interest.

Expertsmind brings you unique solution in java assignments Reflection API Uses of Reflection with java assignment help Reflection is widely used by applications which

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

create a small database for a company, require at least 4 tables. also, have 4 business report, oracle built-in function, 5 string, 5 number or math functions, 5 date and time func

1 Problem Description The task of the assignment is to build a book recommendation system for Auer Libraries. The system is to be implemented in Prolog and as the owners of t

Calculate the total price to purchase all the components required to build a state-of-the-art gaming computer from components available on the internet. Before attempting this exer

Define Call by value - Computer Programming? Functions are raise by writing their name and an appropriate list of arguments within parenthesis. Usually these arguments are in t