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

Assembly language, how to concatinate two strings in assembly

how to concatinate two strings in assembly

Built a liner program to manage a staff, A manager at the local Walmart nee...

A manager at the local Walmart needs to determine how many workers to hire to cover a 24-hour period. Each worker must work 9 consecutive hours but may only start work at the begin

Pros and cons of Assembly language, What are the main pros and cons of asse...

What are the main pros and cons of assembly programming language?

What is .net technology?, What is .NET TECHNOLOGY? .NET technological ...

What is .NET TECHNOLOGY? .NET technological innovation was presented by Enthusiasm, to get the industry from the SUN's Coffee. Few in the past, Enthusiasm had only VC++ and VB

Write a program that makes a drawing of a skyscraper, 1. Write a program th...

1. Write a program that figures out how long it will take to pay off a credit card by making payments of $10 each month. Take care to avoid infinite loops. (How would a bank preven

Vb assignment, Design an application that opens and analyses word files. R...

Design an application that opens and analyses word files. Requirements: Create an application that analyses text documents. It should open a text file, read each word into an ap

Program 3, An apartment complex has several apartments to rent. The apartme...

An apartment complex has several apartments to rent. The apartments are all similar, and all rent for $750 per month. Currently, all units are occupied. The management, being in bu

Virtual Logic and Arrays, My programming class uses Virtual Logic (not virt...

My programming class uses Virtual Logic (not virtual studio) to learn how to program algorithms but we don''t get any assistance form the instructor so I am at a loss as to how I a

Create c sharp classes needed to track creature viability, P4's goal is to ...

P4's goal is to design the C# classes needed to track creature viability in a MMO game under development .  Part I: Class design 1)  GameCreature class (with derived ty

Understanding the html document object model, At the core of DHTML is the D...

At the core of DHTML is the Document Object Model, or DOM, which represents the HTML or XML of a Web page that is displayed in a browser. The Document Object Model that represents

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