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

Author Question: Fill in the code to complete the following function for computing a Fibonacci number.public static ... (Read 98 times)

Bernana

  • Hero Member
  • *****
  • Posts: 530

Question 1

What is the printout of invoking xfunction(1234)?

public static void xfunction(int n) {
if (n > 0) {
System.out.print(n % 10 + " ");
xfunction(n / 10);
}
}

◦ 4 3 2 1
◦ 1 2 3 4
◦ 1234
◦ 4321

Question 2

Fill in the code to complete the following function for computing a Fibonacci number.

public static int fib(int index) {
if (index == 0 || index == 1) // Base case
________
else // Reduction and recursive calls
return fib(index - 1) + fib(index - 2);
}

◦ return 2
◦ return 1
◦ return index
◦ return 0


Related Topics

Need homework help now?

Ask unlimited questions for free

Ask a Question
Marked as best answer by Bernana on May 6, 2020

Rilsmarie951

  • Sr. Member
  • ****
  • Posts: 316
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 49% of students answer this correctly




Bernana

  • Member
  • Posts: 530
Reply 2 on: May 6, 2020
Great answer, keep it coming :)


mcabuhat

  • Member
  • Posts: 344
Reply 3 on: Yesterday
Excellent

 

Did you know?

Eating food that has been cooked with poppy seeds may cause you to fail a drug screening test, because the seeds contain enough opiate alkaloids to register as a positive.

Did you know?

In most climates, 8 to 10 glasses of water per day is recommended for adults. The best indicator for adequate fluid intake is frequent, clear urination.

Did you know?

Blood in the urine can be a sign of a kidney stone, glomerulonephritis, or other kidney problems.

Did you know?

Anesthesia awareness is a potentially disturbing adverse effect wherein patients who have been paralyzed with muscle relaxants may awaken. They may be aware of their surroundings but unable to communicate or move. Neurologic monitoring equipment that helps to more closely check the patient's anesthesia stages is now available to avoid the occurrence of anesthesia awareness.

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.

For a complete list of videos, visit our video library