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]
2 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]2 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
A word I know, six letters it contains, remove one letter and 12 remains, what is it?
gulaghasi [49]

Answer:

dozens

Explanation:

3 0
3 years ago
MODS ONLY answer this, I have something for you. I'm reporting this to make it easier
aliya0001 [1]

Answer:

whyyyyy

have  a good day :)

Explanation:

7 0
3 years ago
Which of the following is not a valid SQL command? (Points : 2) UPDATE acctmanager SET amedate = SYSDATE WHERE amid = 'J500';
Volgvan

Answer:

UPDATE acctmanager WHERE amid = 'J500';

Explanation:

The statement written above is not valid SQL statement because there is no SET after UPDATE. Update is always used with SET.If you are updating something then you need to specify the value with which that value should be replaced.

UPDATE acctmanager SET amname = UPPER(amname);

This statement does not contains WHERE clause but it will run all the values of amname column will get updated in the table acctmanager.

6 0
2 years ago
How much cell phone data does the average person use a month
azamat
It all depends on what you're doing online.
7 0
2 years ago
After clicking the Start button on your computer screen desktop, what option would you then select to examine system components
Sveta_85 [38]
You can find the components that you wanted to modify in : C. control panel

You can adjust your computer's setting through control panel, whether it's your system and security, hardware, net work setting, etc

hope this helps
4 0
3 years ago
Read 2 more answers
Other questions:
  • What does the picture indicate on the famous book “Dawn of the century”?​
    10·1 answer
  • Diane wants to maintain a record of grades scored in the fifth, sixth, and seventh grades. She enters her grades and the total p
    13·1 answer
  • What does “int” means in php code
    13·1 answer
  • What is the basic difference between a printer and a plotter?​
    12·1 answer
  • TRUE AND FALSE
    10·1 answer
  • A regional transportation and logistics company recently hired its first ChiefInformation Security Officer (CISO). The CISO’s fi
    7·1 answer
  • What actions might contribute to recommendations you see online?
    9·1 answer
  • Which term refers to the use of the internet at work for personal use?.
    12·1 answer
  • Which original VPN protocol is supported by most platforms but offers low levels of security?
    12·1 answer
  • Imagine an everyday scenario in which you are using the internet: downloading a file, uploading a photo, checking your email, et
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!