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
Refrigerant-134a enters the expansion valve of a refrigeration system at 120 psia as a saturated liquid and leaves at 20 psia. D
Shkiper50 [21]

Solution :

$P_1 = 120 \ psia$

$P_2 = 20 \ psia$

Using the data table for refrigerant-134a at P = 120 psia

$h_1=h_f=40.8365 \ Btu/lbm$

$u_1=u_f=40.5485 \ Btu/lbm$

$T_{sat}=87.745^\circ  F$

∴ $h_2=h_1=40.8365 \ Btu/lbm$

For pressure, P = 20 psia

$h_{2f} = 11.445 \ Btu/lbm$

$h_{2g} = 102.73 \ Btu/lbm$

$u_{2f} = 11.401 \ Btu/lbm$

$u_{2g} = 94.3 \ Btu/lbm$

$T_2=T_{sat}=-2.43^\circ  F$

Change in temperature, $\Delta T = T_2-T_1$

                                         $\Delta T = -2.43-87.745$

                                           $\Delta T=-90.175^\circ  F$

Now we find the quality,

$h_2=h_f+x_2(h_g-h_f)$

$40.8365=11.445+x_2(91.282)$

$x_2=0.32198$

The final energy,

$u_2=u_f+x_2.u_{fg}$

   $=11.401+0.32198(82.898)$

   $=38.09297 \ Btu/lbm$

Change in internal energy  

$\Delta u= u_2-u_1$

   = 38.09297-40.5485

  = -2.4556        

5 0
2 years ago
Explain the purpose of wrench plzzz
Rus_ich [418]

Answer:

Wrenches are made in various shapes and sizes and are used for gripping, fastening, turning, tightening and loosening things like pipes, pipe fittings, nuts and bolts. There are basically two major kinds of wrenches: Pipe wrenches used in plumbing for gripping round (cylindrical) things.

4 0
2 years ago
Read 2 more answers
In a production turning operation, the foreman has decreed that a single pass must be completed on the cylindrical workpiece in
stellarik [79]

Answer:

V = 125.7m/min

Explanation:

Given:

L = 400 mm ≈ 0.4m

D = 150 mm ≈ 0.15m

T = 5 minutes

F = 0.30mm ≈ 0.0003m

To calculate the cutting speed, let's use the formula :

T = \frac{pi* D * L}{V*F}

We are to find the speed, V. Let's make it the subject.

V = \frac{pi* D * L}{F*T}

Substituting values we have:

V = \frac{pi* 0.4 * 0.15}{0.0003*5}

V = 125.68 m/min ≈ 125.7 m/min

Therefore, V = 125.7m/min

7 0
3 years ago
Find the Rectangular form of the following phasors?
almond37 [142]

Answer:

The angles are missing in the question.

The angles are :

45,     30,    60,     90,    -34,     -56,      20,     -42,  -65,    -15

P=10, P=5,  P=25, P=54, P=65, P=95, P=250, P=8, P=35, P=150

Explanation:

1. P = 10,   θ = 45°  rectangular coordinates

x = r cosθ  ,   y = r sinθ

So, rectangular form is x + iy

x = P cosθ = 10 cos 45°

  = 7.07

y =P sinθ = 10 sin 45°

  = 7.07

Therefore, rectangular form

x + iy = 7.07 + i (7.07)

2. P = 5 , θ = 30°

x = 5 cos  30° = 4.33

y = 5 sin  30° = 2.5

So, (x+iy) = 4.33 + i (2.5)

3. P = 25 , θ = 60°

x = 25 cos  60° = 12.5

y = 25 sin  60° = 21.65

So, (x+iy) = 12.5 + i (21.65)

4. P = 54 , θ = 90°

x = 54 cos  90° = 0

y = 54 sin  90° = 54

So, (x+iy) = 0+ i (54)

5. P = 65 , θ = -34°

x = 65 cos  (-34°) = 53.88

y = 65 sin  (-34°) = -36.34

So, (x+iy) = 53.88 - i (36.34)

6. P = 95 , θ = -56°

x = 95 cos  (-56)° = 53.12

y = 95 sin  (-56)° = -78.75

So, (x+iy) = 53.12 - i (78.75)

7. P = 250 , θ = 20°

x = 250 cos  20° = 234.92

y = 250 sin 20° = 85.5

So, (x+iy) = 234.92 + i (85.5)

8. P = 8 , θ = (-42)°

x = 8 cos  (-42)° = 5.94

y = 8 sin  (-42)° = -5.353

So, (x+iy) = 5.94 - i (5.353)

9. P = 35 , θ = (-65)°

x = 35 cos  (-65)° = 14.79

y = 35 sin  (-65)° = -31.72

So, (x+iy) = 14.79 - i (31.72)

10. P = 150 , θ = (-15)°

x = 150 cos  (-15)° = 144.88

y = 150 sin  (-15)° = -38.82

So, (x+iy) = 144.88 - i (38.82)

6 0
2 years ago
A heat exchanger takes compressed liquid water and converts it into steam with a temperature and pressure of 20 Mpa and 480 C; r
belka [17]

Answer:

See explaination

Explanation:

Lets first consider the term Isentropic efficiency. The isentropic efficiency of a compressor or pump is defined as the ratio of the work input to an isentropic process, to the work input to the actual process between the same inlet and exit pressures. IN practice, compressors are intentionally cooled to minimize the work input.

Please kindly check attachment for the step by step solution of the given problem.

6 0
3 years ago
Other questions:
  • Consider a circular grill whose diameter is 0.3 m. The bottom of the grill is covered with hot coal bricks at 961 K, while the w
    10·1 answer
  • PLZ HURRY IM ON A TIMER
    6·1 answer
  • A soil has the following Green-Ampt parameters Effective porosity 0.400 Initial volumetric moisture content-15% Hydraulic Conduc
    6·1 answer
  • How do you connect several springs to increase the equivalent stiffness? What is one example from industry or other real-life si
    7·1 answer
  • WHAT IS THE EFFECT OF ICE ACCRETION ON THE LONGITUDINAL STABILITY OF AN AIRCRAFT?
    8·1 answer
  • In a hydraulic system, a 100.-newton force is applied to a small piston with an area of 0.0020 m2. What pressure, in pascals, wi
    13·1 answer
  • Which of the following is an example of a social need?
    5·1 answer
  • 7 to 1 inch above the stock
    5·1 answer
  • What is a transition? A. An animation that happens on a single slide B. An outline format that uses roman numerals C. An image f
    10·1 answer
  • Can you help me with this task/homework.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!