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
In a computer-controlled greenhouse, a temperature sensor and a window motor are connected to the computer.
GrogVix [38]
Hope this helps solve it

8 0
3 years ago
Why doesn't brainly give me 15 questions a day
Lilit [14]
I’m not sure how to answer that
8 0
3 years ago
Read 2 more answers
Earthquakes happen in the Earth’s
Nostrana [21]
Earthquakes happen in the Earths "CRUST" because all of the tetonical plates are located in the crust.

hope this helped
5 0
3 years ago
Which is a benefit of owning a desktop computer instead of a laptop?
Setler79 [48]
B) a desktop is less likely to be stolen or damaged
4 0
4 years ago
Read 2 more answers
Shannon has been a member of her schools newpaper club for 2 years and attends writing workshops in her free time. Which career
kkurt [141]

D) Web content developer

Explanation:

A content developer writes a well-researched content for websites, publications, and television. They also write sales copy and other marketing material for online and offline marketing. They develop text, graphics, audios, and videos.  

Skills that help web content developer:

  1. Reading news every day  
  2. Write regularly
  3. Study end audience
  4. Develop original and unique content
  5. Research; reading other people's content as well
  6. Provide solutions through your content

Besides these, a web content writer must possess technical skills like front-end web development. They must know basic HTML formatting and search engine optimization.  

7 0
3 years ago
Other questions:
  • What is the best web browser to use?
    9·2 answers
  • When you minimize a file, folder, or window it is placed on the
    10·1 answer
  • How is a ink pen better than a digital pen.
    8·1 answer
  • What are two examples of management information systems?
    12·1 answer
  • ________________are programs that designed to help users to be more productive with their personal tasks
    11·2 answers
  • Green field country is planning to conduct a cricket match between two teams A and B. a large crowd is expected in the stadium a
    6·1 answer
  • Autumn suffers from nocturnal dyspnea. This term describes a breathing condition but using the prefixes to translate, it means:
    5·1 answer
  • True or False: The major advantage of Arrays over ArrayLists in Java is the fact that while ArrayLists are fixed in size, an Arr
    15·1 answer
  • When solving a problem in a group situation, which of the following traits should be demonstrated?
    8·1 answer
  • Identify the network and the host address in the ip address of 12.128.120.131 with a subnet mask of 255.128.0.0.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!