This topic contains a solution. Click here to go to the answer

Author Question: What is wrong with the following recursive sum method? The method is supposed to sum up the values ... (Read 177 times)

chandani

  • Hero Member
  • *****
  • Posts: 541
What is wrong with the following recursive sum method?  The method is supposed to sum up the values between 1 and x (for instance, sum(5) should be 5 + 4 + 3 + 2 + 1 = 15).

◦ the base case should return 1 instead of 0
◦ the recursive case should return sum(x - 1) + 1; instead of sum(x - 1) + x;
◦ the base case condition should be (x <= 0) instead of (x = = 0)
◦ the recursive case should return sum(x) + 1;
◦ the method should return a boolean instead of an int


Related Topics

Need homework help now?

Ask unlimited questions for free

Ask a Question
Marked as best answer by chandani on Aug 30, 2020

DylanD1323

  • Sr. Member
  • ****
  • Posts: 314
Lorsum iprem. Lorsus sur ipci. Lorsem sur iprem. Lorsum sur ipdi, lorsem sur ipci. Lorsum sur iprium, valum sur ipci et, vala sur ipci. Lorsem sur ipci, lorsa sur iprem. Valus sur ipdi. Lorsus sur iprium nunc, valem sur iprium. Valem sur ipdi. Lorsa sur iprium. Lorsum sur iprium. Valem sur ipdi. Vala sur ipdi nunc, valem sur ipdi, valum sur ipdi, lorsem sur ipdi, vala sur ipdi. Valem sur iprem nunc, lorsa sur iprium. Valum sur ipdi et, lorsus sur ipci. Valem sur iprem. Valem sur ipci. Lorsa sur iprium. Lorsem sur ipci, valus sur iprem. Lorsem sur iprem nunc, valus sur iprium.
Answer Preview
Only 39% of students answer this correctly




chandani

  • Member
  • Posts: 541
Reply 2 on: Aug 30, 2020
Thanks for the timely response, appreciate it


raili21

  • Member
  • Posts: 324
Reply 3 on: Yesterday
YES! Correct, THANKS for helping me on my review

 

Did you know?

Excessive alcohol use costs the country approximately $235 billion every year.

Did you know?

All patients with hyperparathyroidism will develop osteoporosis. The parathyroid glands maintain blood calcium within the normal range. All patients with this disease will continue to lose calcium from their bones every day, and there is no way to prevent the development of osteoporosis as a result.

Did you know?

The FDA recognizes 118 routes of administration.

Did you know?

In ancient Rome, many of the richer people in the population had lead-induced gout. The reason for this is unclear. Lead poisoning has also been linked to madness.

Did you know?

Amoebae are the simplest type of protozoans, and are characterized by a feeding and dividing trophozoite stage that moves by temporary extensions called pseudopodia or false feet.

For a complete list of videos, visit our video library