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 gasoline engine has a piston/cylinder with 0.1 kg air at 4 MPa, 1527◦C after combustion, and this is expanded in a polytropic
Roman55 [17]

Answer:

The expansion work is 71.24 kJ and heat transfer is -16.89 kJ

Explanation:

From ideal gas law,

Initial volume (V1) = nRT/P

n is the number of moles of air in the cylinder = mass/MW = 0.1/29 = 0.00345 kgmol

R is gas constant = 8314.34 J/kgmol.K

T is initial temperature = 1527 °C = 1527+273 = 1800 K

P is initial pressure = 4 MPa = 4×10^6 Pa

V1 = 0.00345×8314.34×1800/(4×10^6) = 0.013 m^3

V2 = 10×V1 = 10×0.013 = 0.13 m^3

The process is a polytropic expansion process

polytropic exponent (n) = 1.5

P2 = P1(V1/V2)^n = 4×10^6(0.013/0.13)^1.5 = 1.26×10^5 Pa

Expansion work = (P1V1 - P2V2) ÷ (n - 1) = (4×10^6 × 0.013 - 1.26×10^5 × 0.13) ÷ (1.5 - 1) = 35620 ÷ 0.5 = 71240 J = 71240/1000 = 71.24 kJ

Heat transfer = change in internal energy + expansion work

change in internal energy (∆U) = Cv(T2 - T1)

T2 = PV/nR = 1.26×10^5 × 0.13/0.00345×8314.34 = 571 K

Cv = 20.785 kJ/kgmol.K

∆U = 20.785(571 - 1800) = -25544.765 kJ/kgmol × 0.00345 kgmol = -88.13 kJ

Heat transfer = -88.13 + 71.24 = -16.89 kJ

5 0
3 years ago
The basic barometer can be used to measure the height of a building. If the barometric readings at the top and at the bottom of
bixtya [17]

Answer:

h = 287.1 m

Explanation:

the density of mercury \rho =13570 kg/m3

the atmospheric pressure at the top of the building is

p_t = \rho gh  = 13570*908*0.73 = 97.08 kPa

the atmospheric pressure at bottom

p_b = \rho gh  = 13570*908*0.75 = 100.4 kPa

\frac{w_{air}}{A} =p_b -p_t

we have also

(\rho gh)_{air} = p_b - p_t

1.18*9.81*h = (100.4 -97.08)*10^3

h = 287.1 m

7 0
3 years ago
When a circuit has more resistance, what happens to current flow ?
zloy xaker [14]
The relationship between resistance and the area of the cross section of a wire is inversely proportional . When resistance is increased in a circuit , for example by adding more electrical components , the current decreases as a result.
6 0
3 years ago
A wooden pallet carrying 540kg rests on a wooden floor. (a) a forklift driver decides to push it without lifting it.what force m
kicyunya [14]

Answer:

The appropriate solution is "1481.76 N".

Explanation:

According to the question,

Mass,

m = 540 kg

Coefficient of static friction,

\mu_s = 0.28

Now,

The applied force will be:

⇒ F=\mu_s mg

By substituting the values, we get

       =0.28\times 540\times 9.8

       =1481.76 \ N

8 0
2 years ago
Doubling the diameter of a solid, cylindrical wire doubles its strength in tension.
julsineya [31]

Answer:

True ❤️

-Solid by solid can make Cylindrical wire doubles Strengths in tension

4 0
3 years ago
Other questions:
  • What is the reason for the development of new construction of materials for human use? (Select all that apply.)
    12·1 answer
  • After a capacitor is fully chargerd, a small amount of current will flow though it. what is this current called?
    14·1 answer
  • A small pad subjected to a shearing force is deformed at the top of the pad 0.12 in. The heigfit of the pad is 1.15 in. What is
    7·1 answer
  • or a metal pipe used to pump tomato paste, the overall heat- transfer coefficient based on internal area is 2 W/(m2 K). The insi
    14·1 answer
  • A strong base (caustic or alkali) is added to oils to test for: b. entrained air a)- alkalinity b)- acidity c)- contamination. d
    11·1 answer
  • Identify SIX (6) objectives of maintenance.<br>​
    5·1 answer
  • While discussing the diagnosis of an EI system in which the crankshaft and camshaft sensor tests are satisfactory but a spark te
    13·1 answer
  • ░░░░░░░░░░░░░░░░░░░▄▀▐░░░▌
    15·1 answer
  • Water is pumped from a lake to a storage tank 18 m above at a rate of 70 L/s while consuming 20.4 kW of electric power. Disregar
    13·1 answer
  • Why is California a good place for engineers to build suspension bridges?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!