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 165 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
Excellent


nguyenhoanhat

  • Member
  • Posts: 332
Reply 3 on: Yesterday
Wow, this really help

 

Did you know?

There are more nerve cells in one human brain than there are stars in the Milky Way.

Did you know?

Blastomycosis is often misdiagnosed, resulting in tragic outcomes. It is caused by a fungus living in moist soil, in wooded areas of the United States and Canada. If inhaled, the fungus can cause mild breathing problems that may worsen and cause serious illness and even death.

Did you know?

Addicts to opiates often avoid treatment because they are afraid of withdrawal. Though unpleasant, with proper management, withdrawal is rarely fatal and passes relatively quickly.

Did you know?

Although not all of the following muscle groups are commonly used, intramuscular injections may be given into the abdominals, biceps, calves, deltoids, gluteals, laterals, pectorals, quadriceps, trapezoids, and triceps.

Did you know?

In 2012, nearly 24 milliion Americans, aged 12 and older, had abused an illicit drug, according to the National Institute on Drug Abuse (NIDA).

For a complete list of videos, visit our video library