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
The following is a function:
Lunna [17]

Answer:

c

Explanation:

i took test

7 0
2 years ago
The keyboard and the mouse are types of BLANK devices
Stolb23 [73]
Input is the right answer.hope it helps.
3 0
3 years ago
Read 2 more answers
Luminaires for fixed lighting installed in Class II, Division 2 locations shall be protected from physical damage by a suitable
ser-zykov [4K]

Given what we know, the protection for fixed lightings like the ones described in the question is by way of a guard or by location.

<h3>Why is protection necessary?</h3>

Luminaires, as with all lighting solutions, can be dangerous if proper safety precautions are not taken. The precautions, in this case, include a safe installation location or the use of a guard to prevent damage to the lighting and subsequently to any nearby occupants of the location.

Therefore, we can confirm that Luminaires for fixed lighting installed in Class II, Division 2 locations shall be protected from physical damage by a suitable guard or by a safe location.

To learn more about Electrical safety visit:

brainly.com/question/14144270?referrer=searchResults

4 0
3 years ago
Assume that x is a char variable that has been declared and already given a value. Write an expression whose value is true if an
maria [59]

Answer:

^[A-Fa-f0-9]+$

Explanation:

The hexadecimal (Base 16) can contain 0-9, A-F, a-f and any of these can be the part of the Hexadecimal base 16 code.

In python we have the re.match function, and the syntax is as below:

re.match(pattern, string, flag=0). And we can use this function to check whether the entered char variable is a regex or not. Like:

re.match(pattern,x, flag=0)

8 0
4 years ago
Which of these improved the ability to send information over the network in the 1970s?
frez [133]

Answer:

b. ethernet

Explanation:

It was an ethernet that was developed in the 1970s that improved the ability to send the information over the network. It is the most widely used method to connect the computers in a LAN or the local area network, ever since 1980 when it was first introduced for commercial use. And it is being used in bulk even today.

4 0
3 years ago
Other questions:
  • Several steps are involved in creating a presentation. what is the last step in the process before preparing to presenting it?
    12·1 answer
  • What is a alt key and how does it work
    14·2 answers
  • Discuss some design considerations that you should keep in mind when you want to design a professional-looking flyer or newslett
    5·2 answers
  • At what point in a vulnerability assessment would an attack tree be utilized?
    9·1 answer
  • Charlie wants you to include the following topics in your presntation: an overview of project management and its hrity,a descrip
    15·1 answer
  • The primary reason for a company to outsource jobs is to
    8·2 answers
  • True or False: In Google Cloud IAM: if a policy applied at the project level gives you Owner permissions, your access to an indi
    8·1 answer
  • Importance of Microsoft access​
    5·1 answer
  • What are your thoughts on copyright?<br><br> (Write 2 or more sentences)
    9·2 answers
  • HELP ME PLEASE
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!