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 program that will allow the user to input the corners of a triangle. The program will draw small yellow circles for each input point, then draw the triangle and calculate t

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

1. A readme.txt file with: a. Instructions on how to compile and run your client and server code on the command line. (Also provide shell scripts if the commands are complicated

Your task for this project is to develop a system that would provide the following features: 1. Register new student 2. Drop student from university 3. Add a course and gr

OTRS Customisation using Perl, MySQL Programming OTRS is a perl based open source issue ticket management solution. Default performance features 'note-internal' that is visible

Object-oriented programming paradigm Object  Oriented  Programming  is  an  aproach  in  which  a  program  is  viewed  as  a  dynamic  network  of collaborating objects, where

write a procedure to add toolbar in VB application adding icons to toolbar buttons & with the approprite example display the use of each button

On-line fair and ethical share trading system (Olfest) A system is required that allows on-line customers to buy and sell stock market shares in a selection of companies. B

Task 1 Think about a Web site you would like to work on for Assignment 2. For example, you can do a personal interest site, a site for your favourite nonprofit organization,

,how to write matlab program for fast decoupled method