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
slava [35]
3 years ago
15

Write a iterative function that finds the n-th integer of the Fibonacci sequence. Then build a minimal program (main function) t

o test it. That is, write the fib() solution as a separate function and call it in your main() function to test it. For reference see Fibonacci number. INPUT OUTPUT (0, 2) (1, 3) (2, 5) 5 INPUT: OUTPUT: (0, 2) (1, 3) (2, 5) (3, 8) (4, 13) 13 INPUT: OUTPUT: (0, 2) 6765 (1, 3) (2, 5) (3, 8) (4, 13) (5, 21) (6, 34) (7, 55) (8, 89) (9, 144) (10, 233) Note, the first number in the pair is the iteration count (i) and the second number is the value of the (i+2)-th Fibonacci value. Problem 2 Write a recursive function that finds the n-th integer of the Fibonacci sequence. Then build a minimal program to test it. For reference see Fibonacci number. To check for recursion, please have the Fibonacci function print out its input as shown in the examples below: INPUT: OUTPUT: fib(5) fib(4) fib(3) fib(2) fib(1) fib(0) fib(1) fib(2) fib(1) fib(0) fib(3) fib(2) fib(1) INPUT: OUTPUT: fib(7) fib(6) fib(5) fib(4) fib(3) fib(2) fib(1) fib(0) fib(1) fib(2) fib(1) fib(0) fib(3) 13 Problem 3 In this problem, you need to print the pattern of the following form containing the numbers from 1 to n: 4 4 4 4 4 4 4 4 3 3 3 3 3 4 4 3 2 2 2 3 4 4 3 2 1 2 3 4 4 3 2 2 2 3 4 4 3 3 3 3 3 4 4 4 4 4 4 4 4 Example when n=4. INPUT Input contains a single integer n. CONSTRAINTS • 1 <= n <= 1000 OUTPUT Print the pattern mentioned in the problem statement. EXAMPLES: INPUT: INPUT: OUTPUT: 2 2 2 2 1 2 2 2 2 INPUT: 5 OUTPUT: 5 5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 4 5 5 4 3 3 3 3 3 4 5 5 4 3 2 2 2 3 4 5 5 4 3 2 1 2 3 4 5 5 4 3 2 2 2 3 4 5 5 4 3 3 3 3 3 4 5 5 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 INPUT: 7 INPUT: 7 OUTPUT: 7 7 7 7 7 7 7 7 7 7 7 7 7 7 6 6 6 6 6 6 6 6 6 6 6 7 7 6 5 5 5 5 5 5 5 5 5 6 7 7 6 5 4 4 4 4 4 4 4 5 6 7 7 6 5 4 3 3 3 3 3 4 5 6 7 7 6 5 4 3 2 2 2 3 4 5 6 7 7 6 5 4 3 2 1 2 3 4 5 6 7 7 6 5 4 3 2 2 2 3 4 5 6 7 7 6 5 4 3 3 3 3 3 4 5 6 7 7 6 5 4 4 4 4 4 4 4 5 6 7 7 6 5 5 5 5 5 5 5 5 5 6 7 7 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7
Engineering
2 answers:
Natasha2012 [34]3 years ago
7 0

Answer:

Codes for each of the problems are explained below

Explanation:

PROBLEM 1 IN C++:

#include<iostream>

using namespace std;

//fib function that calculate nth integer of the fibonacci sequence.

void fib(int n){

  // l and r inital fibonacci values for n=1 and n=2;

  int l=1,r=1,c;

 

  //if n==1 or n==2 then print 1.

  if(n==1 || n==2){

      cout << 1;

      return;

  }

  //for loop runs n-2 times and calculates nth integer of fibonacci sequence.

  for(int i=0;i<n-2;i++){

      c=l+r;

      l=r;

      r=c;

      cout << "(" << i << "," << c << ") ";

  }

  //prints nth integer of the fibonacci sequence stored in c.

  cout << "\n" << c;

}

int main(){

  int n; //declared variable n

  cin >> n; //inputs n to find nth integer of the fibonacci sequence.

  fib(n);//calls function fib to calculate and print fibonacci number.

}

PROBLEM 2 IN PYTHON:

def fib(n):

   print("fib({})".format(n), end=' ')

   if n <= 1:

       return n

   else:

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

if __name__ == '__main__':

   n = int(input())

   result = fib(n)

   print()

   print(result)

andre [41]3 years ago
6 0

You literally wrote gibberish so how do you expect us to answer this question. Even the other person who answered didn't know what he was talking about. :C

You might be interested in
The yield strength of mild steel is 150 MPa for an average grain diameter of 0.038 mm ; yield strength is 250 MPa for average gr
djyliett [7]

Answer:

Explanation:

Hall-Petch equation provides direct relations between the strength of the material and the grain size:

σ=σ0+k/√d , where d- grain size, σ- strength for the given gran size, σ0 and k are the equation constants.

As in this problem, we don't know the constants of the equation, but we know two properties of the material, we are able to find them from the system of equations:

σ1=σ0+k/√d1

σ2=σ0+k/√d2 , where 1 and 2 represent 150MPa and 250MPa strength of the steel.

Note, that for the given problem, there is no need to convert units to SI, as constants can have any units, which are convenient for us.

From the system of equations calculations, we can find constant: σ0=55.196 MPa, k=18.48 MPa*mm^(0.5)

Now we are able to calculate strength for the grain diameter of 0.004 mm:

σ=55.196+18.48/(√0.004)=347.39 MPa

The strength of the steel with the grais size of 0.004 mm is 347.39 MPa.

6 0
3 years ago
Two sites are being considered for wind power generation. On the first site, the wind blows steadily at 7 m/s for 3000 hours per
kirill [66]

Solution :

Given :

$V_1 = 7 \ m/s$

Operation time, $T_1$ = 3000 hours per year

$V_2 = 10 \ m/s$

Operation time, $T_2$ = 2000 hours per year

The density, ρ = $1.25 \ kg/m^3$

The wind blows steadily. So, the K.E. = $(0.5 \dot{m} V^2)$

                                                             $= \dot{m} \times 0.5 V^2$

The power generation is the time rate of the kinetic energy which can be calculated as follows:

Power = $\Delta \ \dot{K.E.} = \dot{m} \frac{V^2}{2}$

Regarding that $\dot m \propto V$. Then,

Power $ \propto V^3$ → Power = constant x $V^3$

Since, $\rho_a$ is constant for both the sites and the area is the same as same winf turbine is used.

For the first site,

Power, $P_1= \text{const.} \times V_1^3$

            $P_1 = \text{const.} \times 343 \ W$

For the second site,

Power, $P_2 = \text{const.} \times V_2^3 \ W$

           $P_2 = \text{const.} \times 1000 \ W$

5 0
3 years ago
True/False
sweet [91]

Answer:

false jdbebheuwowjwjsisidhhdd

7 0
3 years ago
List the four processes in the Otto cycle.
OleMash [197]

Answer:

Explanation:

A woman walks due west on the deck of a ship at 3 miyh.The ship is moving north at a speed of 22 miyh.Find the speed and direction of the woman relative to the surface of the water.

7 0
3 years ago
A mixture of air and methane is formed in the inlet manifold of a natural gas-fueled internal combustion engine. The mole fracti
german

Answer:

The mass flow rate of the mixture in the manifold is 6.654 kg/min

Explanation;

In this question, we are asked to calculate mass flow rate of the mixture in the manifold

Please check attachment for complete solution and step by step explanation.

4 0
3 years ago
Other questions:
  • Convert 0.025 in into mm.
    11·2 answers
  • You have designed a treatment system for contaminant Z. The treatment system consists of a pipe that feeds into a CSTR. The pipe
    8·1 answer
  • The textile industry has seen steady growth in the United States.<br> O True<br> O False
    12·1 answer
  • Let CFG G be the following grammar.
    7·2 answers
  • A 1200-kg car moving at 20 km/h is accelerated
    5·1 answer
  • 6 A square silicon chip (k 150 W/m K) is of width w 5 mm on a side and of thickness t 1 mm. The chip is mounted in a substrate s
    9·1 answer
  • A(94,0,14) B(52,56,94) C(10,6,48) D(128,64,10)
    6·1 answer
  • Why is engineering profession important ​
    11·1 answer
  • Air at 403 K and 1 atm enters a convergent nozzle at a velocity of 150
    9·1 answer
  • (i) what assumptions about the relationship between the inputs and output are inherent in this specification? do scatter plots s
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!