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


miss.ashley

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

 

Did you know?

IgA antibodies protect body surfaces exposed to outside foreign substances. IgG antibodies are found in all body fluids. IgM antibodies are the first type of antibody made in response to an infection. IgE antibody levels are often high in people with allergies. IgD antibodies are found in tissues lining the abdomen and chest.

Did you know?

The toxic levels for lithium carbonate are close to the therapeutic levels. Signs of toxicity include fine hand tremor, polyuria, mild thirst, nausea, general discomfort, diarrhea, vomiting, drowsiness, muscular weakness, lack of coordination, ataxia, giddiness, tinnitus, and blurred vision.

Did you know?

ACTH levels are normally highest in the early morning (between 6 and 8 A.M.) and lowest in the evening (between 6 and 11 P.M.). Therefore, a doctor who suspects abnormal levels looks for low ACTH in the morning and high ACTH in the evening.

Did you know?

Although not all of the following muscle groups are commonly used, intramuscular injections may be given into the abdominals, biceps, calves, deltoids, gluteals, laterals, pectorals, quadriceps, trapezoids, and triceps.

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.

For a complete list of videos, visit our video library