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 97 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!


ebonylittles

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

 

Did you know?

Drugs are in development that may cure asthma and hay fever once and for all. They target leukotrienes, which are known to cause tightening of the air passages in the lungs and increase mucus productions in nasal passages.

Did you know?

There are actually 60 minerals, 16 vitamins, 12 essential amino acids, and three essential fatty acids that your body needs every day.

Did you know?

There are more bacteria in your mouth than there are people in the world.

Did you know?

In 1835 it was discovered that a disease of silkworms known as muscardine could be transferred from one silkworm to another, and was caused by a fungus.

Did you know?

Drug-induced pharmacodynamic effects manifested in older adults include drug-induced renal toxicity, which can be a major factor when these adults are experiencing other kidney problems.

For a complete list of videos, visit our video library