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
How does the engine thermostat regulate the engine temperature?​
Inga [223]

Answer:

It's job is to block the flow of coolant to the radiator until the engine has warmed up. Once the engine reaches its operating temperature (generally about 200 degrees F, 95 degrees C), the thermostat opens. By letting the engine warm up as quickly as possible, the thermostat reduces engine wear, deposits and emissions.

6 0
4 years ago
*sapnap teaching you how to drive*
Nataliya [291]

Answer:

yes dream

Explanation:

8 0
3 years ago
Read 2 more answers
In a Series circuit with two identical loads, the voltage across each load will be:
mel-nik [20]
<h3>Option A</h3>

In a Series circuit with two identical loads, the voltage across each load will be:  the same

<h3><u>Explanation:</u></h3>

A series circuit is one with total the loads in a row. There is barely ONE path for electricity to pass. If this circuit was a series of flashbulbs, and one left out, the left bulbs would switch off. T

he current in a series circuit is universally the same and the voltage over the circuit is the amount of the unique voltage drops over each component. The voltage referred to as a series circuit is equivalent to the amount of the individual voltage drops.

8 0
3 years ago
What possible scenarios may happen if you do the task without using PPE?
ale4655 [162]
Without PPE, employees are at risk of Cuts and punctures. Chemical burns. Electric shocks. Exposure to excessive noise or vibration.
8 0
3 years ago
How much power would you need to cool down a closed, 1 Liter container of water from 100°C to 20°C in 5 minutes? (a) 1.1W (b)1.1
qaws [65]

Answer:

The power required to cool the water is 1.11Kw.

Hence the correct option is (b).

Explanation:

Power needed to cool down is equal to heat extract from the water.

Given:

Volume of water is 1 liter.

Initial temperature is 100C.

Final temperature is 20C.

Time is 5 minutes.

Take density of water as 100 kg/m3.

Specific heat of water is 4.186 kj/kgK.

Calculation:

Step1

Mass of the water is calculated as follows:

\rho=\frac{m}{V}

1000=\frac{m}{(1l)(\frac{1m^{3}}{1000l})}

m=1kg

Step2

Amount of heat extraction is calculated as follows:

Q=mc\bigtriangleup T

Q=1(4.186kj/kgk)(\frac{1000 j/kgk}{1 kj/kgk})\times(100-20)

Q=334880 j.

Step3

Power to cool the water is calculated as follows:

P=\frac{Q}{t}

P=\frac{334880}{(5min)(\frac{60s}{1min})}

P=1116.26W

or

P=(1116.26W)(\frac{1Kw}{1000 W})

P=1.11 Kw.

Thus, the power required to cool the water is 1.11Kw.

Hence the correct option is (b).

8 0
4 years ago
Other questions:
  • In the event of a crash, Personal Injury Protection (PIP) coverage pays toward the medical costs for _____.
    6·1 answer
  • Pick a subjectarea/field/topic that you are interested in. For each of the following Bonham- Carver uses of GIS give an example
    7·1 answer
  • Calibrations on a recent version of an operating system showed that on the client side, there is a delay of at least 0.5 ms for
    13·1 answer
  • A Carnot power cycle is executed in a piston-cylinder system using 1 kg of water. The cycle consists of an isobaric expansion of
    7·1 answer
  • 2- A 2-m3 insulated tank containing ammonia at -20 C, 80% quality, is connected by a valve to a line flowing ammonia at 2 MPa, 6
    14·1 answer
  • Air at 105 kPa and 37° C flows upward through a6-cm-diameter inclined duct at a rate of 65 L/s. The duct diameter is then reduce
    12·1 answer
  • List the steps involved in project development.
    14·1 answer
  • A tailgate may have a latch on both sides.<br> O True<br> O False
    10·2 answers
  • What is 395394^8739/980
    8·1 answer
  • Electrical protective devices are designed to automatically
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!