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

Assignment Help:

 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


Related Discussions:- Shell script to generate the series 1+x + x2+ x3+….+xn

C, what is the c.

what is the c.

Matrices and vectors, This section is proposed to be a catch all for severa...

This section is proposed to be a catch all for several of the fundamental concepts which are used occasionally in working with systems of differential equations. There will not be

Add external style sheet in html code, On a single XHTML page, include the ...

On a single XHTML page, include the following two div container elements in the body. Using an external stylesheet, add style to the div elements such that one div has some overlap

C-program, about how to create the program in c

about how to create the program in c

Exception Handling in c++, Exception handling Exception handling is a mech...

Exception handling Exception handling is a mechanism that separates code that detects and handles exceptional circumstances from the rest of your program. Note that an exceptional

Get back data from database by user as search, i have a database having fie...

i have a database having field name title and comm. I want to search by name and get the all data remaining title and comm(comm is integer)

Power of mobile applications, BACKGROUND: This assignment illustrates t...

BACKGROUND: This assignment illustrates the power of mobile applications. OBJECTIVES: 1. Mobile applications DESCRIBED TASK: This is a single part assignment.

Hr system, maake a programme in C of HR system

maake a programme in C of HR system

Cookies management with perl, One of the main strengths of the Perl program...

One of the main strengths of the Perl programming language are its powerful text manipulation features. In this assignment, you will put them to use for writing a Perl program tha

Example problem of modularity, Example problem Imagine that  you  requ...

Example problem Imagine that  you  require  to create  a robot  that  will  roll up  close to a light  lamp  and  stop  a fixed distance from it.  The first question is, how w

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd