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 220 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
Great answer, keep it coming :)


hramirez205

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

 

Did you know?

Certain topical medications such as clotrimazole and betamethasone are not approved for use in children younger than 12 years of age. They must be used very cautiously, as directed by a doctor, to treat any child. Children have a much greater response to topical steroid medications.

Did you know?

Intradermal injections are somewhat difficult to correctly administer because the skin layers are so thin that it is easy to accidentally punch through to the deeper subcutaneous layer.

Did you know?

The Food and Drug Administration has approved Risperdal, an adult antipsychotic drug, for the symptomatic treatment of irritability in children and adolescents with autism. The approval is the first for the use of a drug to treat behaviors associated with autism in children. These behaviors are included under the general heading of irritability and include aggression, deliberate self-injury, and temper tantrums.

Did you know?

More than one-third of adult Americans are obese. Diseases that kill the largest number of people annually, such as heart disease, cancer, diabetes, stroke, and hypertension, can be attributed to diet.

Did you know?

In 2006, a generic antinausea drug named ondansetron was approved. It is used to stop nausea and vomiting associated with surgery, chemotherapy, and radiation therapy.

For a complete list of videos, visit our video library