Write a program to return the sum of the sequence shown below: 1+2^3 +3! +4^3 +5!......n!...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a program to return the sum of the sequence shown below: 1+2^3 +3! +4^3 +5!......n! (if odd) or n^3 (if even) Apply factorial to all odd numbers between 1 to n (inclusive) and apply cube to all even numbers between 1 to n (inclusive) before adding them all. Sample runs are shown below: Please intput a number: 0 0 Please intput a number: 1 1 Please intput a number: 2 9 Please intput a number: 7 5455 Please intput a number: -1 Terminating the program! The program should run until user input one of the following: A negative number Input greater than 14 Write a program to return the sum of the sequence shown below: 1+2^3 +3! +4^3 +5!......n! (if odd) or n^3 (if even) Apply factorial to all odd numbers between 1 to n (inclusive) and apply cube to all even numbers between 1 to n (inclusive) before adding them all. Sample runs are shown below: Please intput a number: 0 0 Please intput a number: 1 1 Please intput a number: 2 9 Please intput a number: 7 5455 Please intput a number: -1 Terminating the program! The program should run until user input one of the following: A negative number Input greater than 14
Expert Answer:
Answer rating: 100% (QA)
mainpy 1 import math 2 def calculatesequencesumn 3 if n 0 or n 1... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
ArrayList and Classes Imagine you want to create a program to keep track of a collection you have. If you don't actually have a collection, you can have your program work as a wish list instead. You...
-
The Julian calendar was a reform of the Roman calendar introduced by Julius Caesar in 46 BC (708 AUC). It took effect in 45 BC (709AUC). It was the predominant calendar in most of Europe, and in...
-
1. (8 pts) Maria is a college student that can earn $10 per hour working at Jimmy Johns. Maria has 80 hours of free time each month that she can split between working and leisure. The graph below...
-
The acquisition committee of KE plc is considering making takeover bids for two competitors, Scot plc, a listed company, and Ring Ltd. Summarised financial data is given below for these companies....
-
1. During the NBA's 2012-2013 regular season, Carmelo Anthony of the New York Knicks scored 157 three-point field goals, 512 two-point field goals, and 425 free throws (worth one point each). How...
-
Ocular Realty Co. pays weekly salaries of $11,750 on Friday for a five-day workweek ending on that day. Journalize the necessary adjusting entry at the end of the accounting period, assuming that the...
-
Analyze the nature of ethnicity and its relationship to the nation-state.
-
Some people like to pour beer gently down the side of the glass to preserve bubbles. Others, splash it down the center to release the bubbles into a foamy head and free the aromas. Champagne, however...
-
1. Your client is charged with two counts of theft that relate to two separate incidents. At the first appearance, you receive a disclosure package from the Crown. Upon reviewing the material, you...
-
A 0.40-m 3 insulated pistoncylinder device initially contains 1.3 kg of air at 30C. At this state, the piston is free to move. Now air at 500 kPa and 70C is allowed to enter the cylinder from a...
-
How did you get the confirmed beginning inventory profit of 2,400?
-
Use the Divergence Theorem to evaluate the flux \(\iint_{\mathcal{S}} \mathbf{F} \cdot d \mathbf{S}\). \(\mathbf{F}(x, y, z)=\langle y, z, xangle, \mathcal{S}\) is the sphere \(x^{2}+y^{2}+z^{2}=1\)....
-
Use a logic analyzer to view system activity on your bus.
-
Implement peek() and poke() in assembly language for ARM.
-
Attach LEDs to your system bus so that you can monitor its activity. For example, use an LED to monitor the read/write line on the bus.
-
Can you think of any other areas of possible focus for a firm besides those identified in Table 1.3? ITABLE 1.3 Common Areas of Organizational Focus Innovation. Bringing a range of new products and...
-
You have been referred a client from a George Stefan from AAMC Financial Planners who is a Financial Planner you have a referrer agreement with. He's asked if you could urgently help his clients as...
-
Don Griffin worked as an accountant at a local accounting firm for five years after graduating from university. Recently, he opened his own accounting practice, which he operates as a corporation....
-
Professor Patricia (Patty) Pate is retired from the PalmSprings Culinary Arts Academy (PSCAA). She is a single taxpayer and is 68 years old. Patty lives at 98 Colander Street, Henderson, NV 89052....
-
Greg died on July 1, 2012, and left Lea, his wife, a $50,000 life insurance policy which she elects to receive at $5,000 per year plus interest for 10 years. In the current year, Lea receives $6,200....
-
Robert Ramos (age 36) is a single taxpayer, living at 8765 Bay Dr., Monterey, CA 93940. His Social Security number is 976-23-5132. Robert's earnings and income tax withholding as the manager of a...
-
A construction engineer has to inspect 5 construction sites in a 2-day inspection schedule. He may or may not be able to visit these sites in two days. He will not visit any site more than once. (a)...
-
An explosion in an LNG storage tank in the process of being repaired could have occurred as the result of static electricity, malfunctioning electrical equipment, an open flame in contact with the...
-
What conditions for the binomial distribution, if any, fail to hold in the following situations? (a) For each of a company's eight production facilities, record whether or not there was an accident...
Study smarter with the SolutionInn App