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
lys-0071 [83]
3 years ago
8

The Fibonacci sequence 1, 1, 2, 3, 5, 8, 13, 21…… starts with two 1s, and each term afterward is the sum of its two predecessors

. Please write a function, Fib(n), which takes n as the input parameter. It will return the n-th number in the Fibonacci sequence. Using R, the output for Fib(9) should give only the 9th element in the sequence and not any of the previous elements. Please Help :)
Engineering
2 answers:
Novay_Z [31]3 years ago
5 0

9th value is 34

Explanation:

R or Fib (n) function is given by: (n - 1) + (n - 2), where n is the number in the Fibonacci sequence .

Hence, fib (9) = (9 - 1) + (9 - 2)

                      = 8th value + 7th value on the sequence summed together  

<em>Fibonacci sequence: 1, 1, 2, 3, 5, 8, 13, 21.</em><em> </em>The 8th value is 21 and the 7th value is 13.  

R = (n - 1) + (n - 2)

R (9) 0r Fib (9) = 21 + 13

           = 34

Olin [163]3 years ago
5 0
<h2>Answer:</h2>

  #Create a function Fib to return the nth term of the fibonacci series

  #Method header declaration

   Fib <- function(n)  {

 

   #when n <= 1, the fibonacci number is 1

   #hence return 1

   if (n <= 1)

           return(1)

   #when n = 2, the fibonacci number is 1

   #hence return 1

   else if (n == 2)

            return(1)

   

   #at other terms, fibonacci number is the sum of the previous two

   #numbers.

   #hence return the sum of the fibonacci of the previous two numbers

   else

           return( Fib(n-1) + Fib(n-2))

   }    #End of method.

============================================================

<h2>Sample Output:</h2>

A call to Fib(9) will give the following output:

>> 34

============================================================

<h2>Explanation:</h2>

The above program has been written in R language and it contains comments explaining each of the lines of code. Please go through the comments in the code.

For readability, the actual lines of code have been written in bold face to distinguish them from the comments.

You might be interested in
A 7-hp (shaft) pump is used to raise water to an elevation of 15 m. If the mechanical efficiency of the pump is 82 percent, dete
Natali [406]

The maximum volume flow rate of water is determined as 0.029 m³/s.

<h3>Power of the pump</h3>

The power of the pump is watt is calculated as follows;

1 hp = 745.69 W

7 hp = ?

= 7 x 745.69 W

= 5,219.83 W

<h3>Mass flow rate of water</h3>

η = mgh/P

mgh = ηP

m = ηP/gh

m = (0.82 x 5,219.83)/(9.8 x 15)

m = 29.12 kg/s

<h3>Maximum volume rate</h3>

V = m/ρ

where;

  • ρ is density of water = 1000 kg/m³

V = (29.12)/(1000)

V = 0.029 m³/s

Learn more about volume flow rate here: brainly.com/question/21630019

#SPJ12

5 0
2 years ago
What energy does a curcuit board run on
son4ous [18]

a curcuit board is powered by energy from the computers power soarce

6 0
3 years ago
Read 2 more answers
What is the answer of this question please tell me <br><br>dadada please please​
charle [14.2K]

lol i neeeeeeeeeeeeeeeeeeeeeeeed pointssssssssssssssss

6 0
3 years ago
Rubber bushings are used on suspensions to
Harlamova29_29 [7]
D. All of the above
4 0
3 years ago
Technician A says that 5W-30 would be better to use than 20W-50 in most vehicles in
shtirl [24]
Technician is correct sorry if im wronghg
5 0
3 years ago
Read 2 more answers
Other questions:
  • How does a carburetor work?
    7·1 answer
  • A stainless-steel specimen from the same material characterized up above, was formed into a rectangular cross-section of dimensi
    9·1 answer
  • The jib crane is supported by a pin at Cand rod AB. The rod can withstand a maximum tension of 40 kN. If the load has a mass of
    11·1 answer
  • Design a digital integrator using the impulse invariance method. Find and give a rough sketch of the amplitude response, and com
    15·1 answer
  • NASA SPACE SHUTTLE QUESTION:
    14·1 answer
  • A manager who focuses on the employees who enable a company to do business is human resource management. True True False False
    7·1 answer
  • Which of the following describes what a manufacturing engineer does
    9·2 answers
  • What is the difference between a natural and artificial diamond ​
    6·2 answers
  • The Environmental Protection Agency (EPA) has standards and regulations that says that the lead level in soil cannot exceed the
    13·1 answer
  • During welding in the vertical position, the torch angle can be varied to control sagging.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!