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
Write a function that converts a character array to a signed floating point number. Function prototype must be as follows: int asciiToFloat( char *str, unsigned char* eflag) Follow

I have 9 assignments to be completed

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

code for using tree view control and fill it with database using asp.net and language vb.net

I''m studying electrical engineering, and this semester im taking course that called Computer Design. in this course they need me to a final project about any thing we took during

Determine the solution to the following differential equation. x 2 y′′ + 3xy′ + 4 y = 0   Solution Find the roots to (3) first as generally. r(r -1) + 3r + 4 = 0 r

Explain the Do - While Statement - Computer Programming? A do - while loop is an exit controlled loop and the body of the loop gets executed at least once if the condition is n

OOPS Concepts Object-oriented programming (OOP) is a computer science term used to characterize a programming language that began development in the 1960’s. The term ‘object-orient

Define Reasons for using Functions? 1. Evade rewriting the same code over and over. 2. It is simpler to write programs and keep track of what they are doing. Codes are able t

Define the Parameter Passing Mechanism - Computer Programming? The Parameters are syntactically identifiers and they are used within the body of the function and sometimes the