1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Svetach [21]
3 years ago
5

Give a recursive algorithm to compute the sum of the cubes of the first n positive integers. The input to the algorithm is a pos

itive integer n. The output is ∑j=1nj3. The algorithm should be recursive, it should not compute the sum using a closed form expression or a loop.
Computers and Technology
1 answer:
DaniilM [7]3 years ago
7 0

Answer:

def sum_cubes(n):

   if n == 1:

       return 1

   else:

       return n * n * n + sum_cubes(n-1)

print(sum_cubes(3))

Explanation:

Create a function called sum_cubes that takes one parameter, n

If n is equal to 1, return 1. Otherwise, calculate the cube of n, and add it to the sum_cubes function with parameter n-1

If we want to calculate the cubes of the first 3 numbers:

sum_cubes(3) = 3*3*3 + sum_cubes(2)

sum_cubes(2) = 2*2*2 + sum_cubes(1)

sum_cubes(1) = 1

If you substitute the values from the bottom, you get 27+8+1 = 36

You might be interested in
The __________ contains a list of all the resources owned by the library.
Ira Lisetskai [31]

The catalog contains a list of all the resources owned by the library.

- Mabel <3

5 0
3 years ago
Use the drop-down tool to match each definition to the correct word or phrase. The computer that responds to requests from the c
Lera25 [3.4K]

Answer:

The computer that responds to requests from the client computer:  

Server

Connects network devices or different parts of a network:  

Switch

A piece of equipment that directs data where it should go:  

Router

Connects many different Ethernet devices and allows them to connect to the network with one connection:  

Hub

The computer that uses service provided by a server:  

Client

Explanation:

6 0
3 years ago
A document repository is down when you attempt to access it. which isa principle is being violated?
Tju [1.3M]
When a document repository is down when you attempt to access it, the ISA principle Authentication is being violated. The authentication method is done during the log on phase and is performed by the ISA server which requests certificate. <span>The client then needs to send the appropriate client certificate to the server in order to be authenticated and to have access to the document.</span>
3 0
3 years ago
What is the meaning of Android
LUCKY_DIMON [66]
For technology:
<span>It is an open-source operating system used for smartphones and tablet computers.
</span><span>In science fiction:
 It is a robot with a human appearance.</span>
6 0
3 years ago
Read 2 more answers
It is important to avoid using a person’s title in an email to avoid offending him or her.
Nataly [62]

The answer to this is FALSE. I just took the test & got 100%.

3 0
3 years ago
Read 2 more answers
Other questions:
  • Different between ocular and compound miscroscope
    13·1 answer
  • An adjustable wrench's movable jaw is positioned <br> by​
    5·1 answer
  • Why might the government censor what its citizens see on the internet?
    13·2 answers
  • What is the best way to show a complex data chart in word?
    6·1 answer
  • Ask what are brainly points for besides asking questions.
    9·1 answer
  • Help teacher said with complete explanation ​
    5·1 answer
  • When using the Photo Album dialog box, a picture
    13·2 answers
  • Developing algorithms using psuedocode
    15·1 answer
  • Best definition of wind
    7·1 answer
  • Network administrators use _____ technology when they need antivirus updates to be automatically downloaded on employees' workst
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!