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
Question 54 (1 point)
Rudiy27
The answer should be Oc 15
6 0
2 years ago
Read 2 more answers
Benzene gas (C6H6) at 25° C and 1 atm, enters a combustion chamber operating at steady state and burns with 95% theoretical air
tiny-mole [99]

Answer:

Explanation:

Benzene gas is burned with 95 percentage theoretical air during a steady â flow combustion process. The mole fraction of the CO in the products and the heat transfer from the combustion chamber are to be determined

Assumption

steady operating conditions exit .

Air and combustion gases are gases

Kinetic and potential energies are negligible

The fuel is burned with insufficient amount of air and thus the products will contain some CO as well as CO2, H2O and H2

Combustion equation is

C6H6 + ath (O2 + 3.76N2) â 6CO2 +3H2O +3.76ath N2

Where ath is the stoichiometric coefficient and is determined from the O2 balance

ath = 6+1.5 = 7.5

then the actual combustion equation can be written as

C6H6 + 0.95 * 7.5(O2 + 3.76N2) â xCO2 + (6-x) CO + 3H2O + 26.79N2

O2 balance: 0.95 * 7.5 = x +(6-x)/2 +1.5 â x=5.25

Thus C6H6 + 7.125(O2 +3.76 N2) â 5.25 CO2 + 0.75CO + 3H2O + 26.79N2

The mole fraction of CO in the products is

yCO = N CO/ N total = 0.75/5.25 + 0.75+3+26.79

=0.021 or 2.1% mole fraction of the CO in the products

5 0
3 years ago
Read 2 more answers
You live on a street that runs East to West. You just had 2 inche of snow and you live on the North side of the street. You retu
RSB [31]

Answer:

The heat from the sun melted it

Explanation:

If the street runs east to west, houses on the south (across the street) will project shadows on their sidewalk, while the northern sidewalk will be illuminated. This is for the northern hemisphere, on the southern hemisphere it would be the other way around.

5 0
3 years ago
When a company in the United States employs people in India to answer their customer service calls this is an example of
fgiga [73]
Answer is : B Outsourcing.
3 0
2 years ago
Which is an alloy made up of iron and carbon and has high compressive and tensile strength?
Digiron [165]

Answer: Steel is an alloy of iron with typically a few percent of carbon to improve its strength and fracture resistance compared to iron. Many other additional elements may be present or added. Stainless steels that are corrosion and oxidation resistant need typically an additional 11% chromium.

Explanation:

3 0
3 years ago
Other questions:
  • Choose the true statement from those shown below: A Merchant Account allows you to use SSL on your web site. Disadvantages of us
    14·1 answer
  • tech a says that a tire with more wear on the center of the tread is caused by under inflation of the size tech b says featherin
    12·1 answer
  • 2.4 kg of nitrogen at an initial state of 285K and 150 kPa is compressed slowly in an isothermal process to a final pressure of
    8·1 answer
  • Evaporation in Double-Effect Reverse-Feed Evaporators. A feed containing 2 wt % dissolved organic solids in water is fed to a do
    14·1 answer
  • Which type of Bridge is considered the strongest in both compression and tension?
    11·2 answers
  • Plateau Creek carries 5.0 m^3 /s of water with a selenium (Se) concentration of 0.0015 mg/L. A farmer withdraws water at a certa
    12·1 answer
  • Please help on two I will give brainiest​
    13·2 answers
  • Which step in the engineering design process likely broke down in the following scenario?
    14·1 answer
  • The pressure less than atmospheric pressure is known as:
    6·1 answer
  • Explain the problems and their possible solution for electricity problems ?​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!