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 94 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
Wow, this really help


matt95

  • Member
  • Posts: 317
Reply 3 on: Yesterday
:D TYSM

 

Did you know?

The types of cancer that alpha interferons are used to treat include hairy cell leukemia, melanoma, follicular non-Hodgkin's lymphoma, and AIDS-related Kaposi's sarcoma.

Did you know?

Asthma occurs in one in 11 children and in one in 12 adults. African Americans and Latinos have a higher risk for developing asthma than other groups.

Did you know?

Egg cells are about the size of a grain of sand. They are formed inside of a female's ovaries before she is even born.

Did you know?

Children of people with alcoholism are more inclined to drink alcohol or use hard drugs. In fact, they are 400 times more likely to use hard drugs than those who do not have a family history of alcohol addiction.

Did you know?

Although the Roman numeral for the number 4 has always been taught to have been "IV," according to historians, the ancient Romans probably used "IIII" most of the time. This is partially backed up by the fact that early grandfather clocks displayed IIII for the number 4 instead of IV. Early clockmakers apparently thought that the IIII balanced out the VIII (used for the number 8) on the clock face and that it just looked better.

For a complete list of videos, visit our video library