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
.NET Windows Services But Enthusiasm has an amazing record of beginning overdue but finding up easily. This is real in situation of .NET too. Enthusiasm put their best men at

Advantages of asp.net mvc framework MVC is a conventional style design that many designers are acquainted with. Some kinds of Web programs will advantage from the MVC structur

Problem 6. Demonstrate how and when can you use the commands- vi, cat, chmod, grep, man, pwd, ps, kill, mkdir, rm demonstrating how and when the above 10 commands can be

The ATM will simulate a real world automated teller machine that supports safe access to accounts from multiple concurrent clients.

Assume that you are a college professor needing to average grades for 10 students. Write a program that asks for each student's name and grade. Print the list on-screen with each s

Define the If - else statement - computer programming? The If - else statement The universal form of if - else statement is                         if(expression)

I need someone to make an ER diagram.

Write a program to read a text file and create a dictionary. The keys for the dictionary should be all 26 letters of the alphabet and the values of the dictionary should be the lis

#1. Every mathematics student likes primes numbers. Every mathematics student like parabolas. Let''s put them together to have some fun: Consider two natural numbers a and b. Of co