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


at

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

 

Did you know?

The people with the highest levels of LDL are Mexican American males and non-Hispanic black females.

Did you know?

Aspirin may benefit 11 different cancers, including those of the colon, pancreas, lungs, prostate, breasts, and leukemia.

Did you know?

According to the FDA, adverse drug events harmed or killed approximately 1,200,000 people in the United States in the year 2015.

Did you know?

More than 4.4billion prescriptions were dispensed within the United States in 2016.

Did you know?

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

For a complete list of videos, visit our video library