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 178 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
Gracias!


alexanderhamilton

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

 

Did you know?

Cocaine was isolated in 1860 and first used as a local anesthetic in 1884. Its first clinical use was by Sigmund Freud to wean a patient from morphine addiction. The fictional character Sherlock Holmes was supposed to be addicted to cocaine by injection.

Did you know?

Thyroid conditions may make getting pregnant impossible.

Did you know?

Hip fractures are the most serious consequences of osteoporosis. The incidence of hip fractures increases with each decade among patients in their 60s to patients in their 90s for both women and men of all populations. Men and women older than 80 years of age show the highest incidence of hip fractures.

Did you know?

Your heart beats over 36 million times a year.

Did you know?

Fungal nail infections account for up to 30% of all skin infections. They affect 5% of the general population—mostly people over the age of 70.

For a complete list of videos, visit our video library