1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Darya [45]
3 years ago
9

Using language c, find the nth Fibonacci, knowing that nth Fibonacci is calculated by the following formula: - If n = 1 Or n = 2

then F(n) = 1 - If n>2 then F(n) = F(n-1) + F(n-2)
Computers and Technology
1 answer:
Nina [5.8K]3 years ago
4 0

Answer:

#include <stdio.h>

int fib(int n) {

 if (n <= 0) {

   return 0;

 }

 if (n <= 2) {

   return 1;

 }

 return fib(n-1) + fib(n-2);

}

int main(void) {

 for(int nr=0; nr<=20; nr++)

   printf("Fibonacci %d is %d\n", nr, fib(nr) );

 return 0;

}

Explanation:

The code is a literal translation of the definition using a recursive function.

The recursive function is not per se a very efficient one.

You might be interested in
What do newly PivotTables look like?
adell [148]

Answer:

Answer is in attached image!

Explanation:

8 0
3 years ago
To copy cell contents, you can select the cell and then press the ____ keys.
LenaWriter [7]
To copy cell contents, you can select the cell and then press the CTRL + C keys. 
They act as a sort of a shortcut, so you don't have to select, right click and then choose copy. 
8 0
4 years ago
Which protocol sends a request to view or download a website or file ​
Paul [167]
The answer is HTTP protocol
5 0
4 years ago
Suppose that bClass is a class. Which of the following statements correctly derives the class dClass from bClass? a. class dClas
DerKrebs [107]

Answer:

The answer to the given question is option "d".

Explanation:

In C++ programming language we use the (:) colon to perform inheritance in the class. The by default access modifier is used for inheritance that is "private". In the given options the option d is correct and other options are not correct that cab be described as:

  • In option, a, b we use the scope resolution operator (::) that is not used for inheritance.
  • In option, c we inherit drive class to base class that is not correct.  

That's why the answer to this question is option "d".

4 0
4 years ago
Flash drive DVD and hard drive are all examples of
oee [108]

Answer:

flash drive DVD and hard drive are all examples of storage device

8 0
3 years ago
Read 2 more answers
Other questions:
  • Write a new function called "listmax" based on the following IPO # function: listmax # INPUT: a list # PROCESSING: obtains the l
    9·1 answer
  • If you need to use arrows in a chart, which feature or menu option of a word processing program would you use?
    13·2 answers
  • Object-oriented development could potentially reduce the time and cost of writing software because: Group of answer choices a) i
    5·1 answer
  • What does artifishal inteligence mean
    5·2 answers
  • TolTel Inc., an information technology firm, has created a network that allows its employees to easily access, share, and publis
    11·1 answer
  • A client contacted you to request your help in researching and supplying the hardware necessary to implement a SOHO solution at
    5·1 answer
  • Which of these programmers creates the core game engine?
    5·2 answers
  • What does the action tool allow you to do in Microsoft Powerpoint?
    15·1 answer
  • What breakthrough in sound recording facilitated stereophonic recording? Ο Α. overdubbing O B. multitrack recording O C. digital
    10·1 answer
  • How to hack a I'd Indian brainly bot​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!