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
The top 3 most popular male names of 2017 are Oliver, Declan, and Henry according to babynames. Write a program that modifies th
Flura [38]

Answer:

The code is given below in Python with appropriate comments

Explanation:

# convert list to set

male_names = set(['Oliver','Declan','Henry'])

# get remove and add name from user

remove_name = input("Enter remove name: ")

add_name = input("Enter add name: ")

# remove name from set

male_names.remove(remove_name)

# add new name ij set

male_names.add(add_name)

# sort the set

a = sorted(male_names)

# print the set

print(a)

7 0
2 years ago
Please help me it’s for science I only have a few minutes
7nadin3 [17]

Answer:

Rocks

Explanation:

I am not sure tho bc they are made out of coal and I think coal is a kind of rock

3 0
2 years ago
Read 2 more answers
A data record of all of someone's online activity is called a
aev [14]

Answer:

The answer is computer cookies.

Explanation:

Smartness :D

4 0
3 years ago
Read 2 more answers
What is your understanding and opinion on the validity of the stand-by equipment maintenance requirement?
Fed [463]

Answer:

  The stand-by equipment is technically required in case where the we need some urgent equipment for the purpose of maintenance in emergency and if the other equipment system get fails. the term stand by means backup equipment and component.

In the reliability engineering, we always need to provide an extra equipment or component in case of emergency. It is basically used so that it does not affect any type of productivity in the organization. It is also increase the redundancy of the equipment.

6 0
3 years ago
The motor of an electric vehicle runs at an average of 50 hp for one hour and 25 minutes. Determine the total energy. Write the
Sunny_sXe [5.5K]

Answer:

The total energy of the motor of the electric vehicle is 1.902 × 10⁸ joules.

Explanation:

Power is the rate of change of work in time, since given input is average power, the total energy (\Delta E) of the motor of the electric vehicle, measured in joules, is determined by this formula:

\Delta E = \dot W \cdot \Delta t

Where:

\dot W - Average power, measured in watts.

\Delta t - Time, measured in seconds.

Now, let convert average power and time into watts and seconds, respectively:

Average Power

\dot W = (50\,hp)\times \frac{746\,W}{1\,hp}

\dot W = 3.730\times 10^{4}\,W

Time

\Delta t = (1\,h)\times \frac{3600\,s}{1\,h} + (25\,min)\times \frac{60\,s}{1\,min}

\Delta t = 5.100\times 10^{3}\,s

Then, the total energy is:

\Delta E = (3.730\times 10^{4}\,W)\cdot (5.100\times 10^{3}\,s)

\Delta E = 1.902\times 10^{8}\,J

The total energy of the motor of the electric vehicle is 1.902 × 10⁸ joules.

6 0
3 years ago
Other questions:
  • To make 1000 containers of ice cream you need: 600 gallons of milk, 275 gallons of cream, and 120 gallons of flavor. Each ingred
    12·1 answer
  • Looking at the response vehicles (pictured above), explain two options you have in order to abide by the Move
    8·1 answer
  • -Mn has a cubic structure with a0 = 0.8931 nm and a density of 7.47 g/cm3. -Mn has a different cubic structure, with a0 = 0.63
    7·1 answer
  • Which of the following activities will allow an engineer to determine that a building's design is sound?
    6·1 answer
  • 5
    15·1 answer
  • Random question, does anyone here use Lego, do not answer unless that is a yes
    15·2 answers
  • The notation on one's license that the person must wear glasses
    9·1 answer
  • How the LED (light emitting diode) works?​
    8·2 answers
  • Outline how effective brainstorming should be set up so that it does not go off-track or alienate anyone.
    15·1 answer
  • Whose responsibility is it to provide direction on correct ladder usage?<br> select the best option.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!