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

Program compares interest rates, 'This program compares interest rates betw...

'This program compares interest rates between two banks and determines the best bank 'Eric Weber, Adam Litchfield, Eric Romero, Sarah, Alex, Amy '10/5/12 'Lab #4 Problem 42 'CSC

Project 1, CSCI 3380 Project 1 For Mano’s Computer design, we have the fol...

CSCI 3380 Project 1 For Mano’s Computer design, we have the following flowchart for fetch and decode phases: Please write the code to simulate the computer to

Create a raptor program - use class in raptor and in python, In this porti...

In this portion of the lab you will analyze a problem and create a Raptor program to solve it.  Make sure you use a class in Raptor and in Python to solve the problem.  Read the fo

Fibonacci in windows assmbly language, Write an assembly program that compu...

Write an assembly program that computes Fibonacci numbers 2-5. a. Assume Fib(0)=0 and Fib(1)=1. b. Store Fib(2) in EAX, Fib(3) in EBX, Fib(4) in ECX and Fib(5) in EDX. c. Use a LOO

Program for nuclear reactor - embedded systems, Implement the "Nuclear Reac...

Implement the "Nuclear Reactor" example using the following:  An ISR triggered by a button press  A task to update the temperatures  A semaphore to communicate between the ISR and

Assembly language, how to concatinate two strings in assembly

how to concatinate two strings in assembly

Write the vhdl code for traffic light controller, The schematic of the traf...

The schematic of the traffic light controller is as shown in figure 1. There are three control buttons on the panel: HAZ (Hazard), LT (Left) and RT (Right). Whenever, HAZ is clicke

Apply generic algorithms in solving programming problems, Educational Objec...

Educational Objectives: After completing this assignment, the student should be able to accomplish the following: Apply generic algorithms in solving programming problems Define an

JUnit test, hi, can you help me with testing java classes I have wrote usin...

hi, can you help me with testing java classes I have wrote using java and jsp and servlet in eclipse ? I want to use JUnit for testing

Genetic algorithm, I need help I want to implement the Genetic Algorithm f...

I need help I want to implement the Genetic Algorithm for Shortest path Kindly Help me I will be thankful to you

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