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]
2 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]2 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]2 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
Express 2/16 in thirty-seconds
mafiozo [28]

Answer:

\frac{2}{16}  = \frac{4}{32} in thirty seconds.

Explanation:

one thirty second is one part out of 32 equal section . It is used to describe amounts accurately.

\frac{2}{16} can be easily expressed as \frac{4}{32}

3 0
2 years ago
Pipe Diameter and Reynolds Number. An oil is being pumped inside a 10.0-mm-diameter pipe at a Reynolds number of 2100. The oil d
alexdok [17]

Answer:

The velocity in the pipe is 5.16m/s. The pipe diameter for the second fluid should be 6.6 mm.

Explanation:

Here the first think you have to consider is the definition of the Reynolds number (Re) for flows in pipes. Rugly speaking, the Reynolds number is an adimensonal parameter to know if the fliud flow is in laminar or turbulent regime. The equation to calculate this number is:

Re=\frac{\rho v D}{\mu}

where \rhois the density of the fluid, \mu is the viscosity, D is the pipe diameter and v is the velocity of the fluid.

Now, we know that Re=2100. So the velocity is:

v=\frac{Re*\mu}{\rho*D} =\frac{2100*2.1x10^{-2}Pa*s }{855kg/m^3*0.01m} =5.16m/s

For the second fluid, we want to keep the Re=2100 and v=5.16m/s. Therefore, using the equation of Reynolds number the diameter is:

D=\frac{Re*\mu}{\rho*v} =\frac{2100*1.5x10^{-2}Pa*s}{925kg/m^3*5.16m/s}=6.6 mm

8 0
3 years ago
4. Partnership programs between schools and the owners
rusak2 [61]

Answer:

Automotive Technology Program

Explanation:

Basically hiring students for hands on training to learn the basics of mechanics.

4 0
2 years ago
Which of the following is NOT true about hydraulic systems?
Dmitry [639]

Answer: The answer is D

D.In hydraulic systems, the operating temperatures must be kept between 170�F and 180°F 

Explanation:

The operating temperature for hydraulic systems is 140°F and below. Anything above this temperature is too high and will reduce the useful life of hydraulic fluid.

Most often problems associated with hydraulic systems are caused by fluid contaminated with particulate matter.

7 0
3 years ago
Ann’s Retail, a women’s clothing store, hires female attendants to assist clients in the store’s dressing rooms. Larry, a male,
mojhsa [17]

Answer:

A bona fide occupational qualification defense

Explanation:

Since the store is for women clothing, the retail may prefer to employ only female to assist the customers.  Under a bona fide occupational qualification defense, an employer is allowed to discriminate if a characteristic is a necessity for the performance of the job and for the business. Therefore, the store has a bona fide occupational qualification defense.

3 0
3 years ago
Other questions:
  • If a vacuum gau ge reads 9.62 psi, it means that: a. the very highest column of mercury it could support would be 19.58 inches.
    11·1 answer
  • Using an "AND" and an "OR", list all information (Equipment Number, Equipment Type, Seat Capacity, Fuel Capacity, and Miles per
    9·1 answer
  • When using fall arrest, free fall must be kept at or below how many feet
    13·1 answer
  • The production of carbon dioxide makes it unwise and unsafe to operate a tractor or any motor vehicle inside enclosed spaces suc
    13·1 answer
  • Which of the following describes what a manufacturing engineer does
    9·2 answers
  • How do guest room hotel smoke alarms work and differ then regular home versions?
    10·2 answers
  • Bằng lý luận và thực tiễn, bạn hãy trình bày ý kiến của mình về quan điểm sau đây: "Quá trình dạy học là quá trình truyền thụ tr
    7·1 answer
  • A tool used to put a concave edge on a plane iron is
    6·1 answer
  • The team needs to choose a primary view for the part drawing. Three team members make suggestions:
    10·1 answer
  • Metal wireways are sheet metal troughs with _____________ for housing and protecting electrical conductors and cable.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!