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
. Using the Newton Raphson method, determine the uniform flow depth in a trapezoidal channel with a bottom width of 3.0 m and si
Over [174]

Answer:

y  ≈ 2.5

Explanation:

Given data:

bottom width is 3 m

side slope is 1:2

discharge is 10 m^3/s

slope is 0.004

manning roughness coefficient is 0.015

manning equation is written as

v =1/n R^{2/3} s^{1/2}

where R is hydraulic radius

S = bed slope

Q = Av =A 1/n R^{2/3} s^{1/2}

A = 1/2 \times (B+B+4y) \times y =(B+2y) y

R =\frac{A}{P}

P is perimeter =  (B+2\sqrt{5} y)

R =\frac{(3+2y) y}{(3+2\sqrt{5} y)}

Q = (2+2y) y) \times 1/0.015 [\frac{(3+2y) y}{(3+2\sqrt{5} y)}]^{2/3} 0.004^{1/2}

solving for y100 =(2+2y) y) \times (1/0.015) [\frac{(3+2y) y}{(3+2\sqrt{5} y)}]^{2/3} \times 0.004^{1/2}

solving for y value by using iteration method ,we get

y  ≈ 2.5

5 0
3 years ago
Write a program that uses a function called Output_Array_Info. Output_Array_Info Properties: Input Parameters: 1. A pointer to a
Artyom0805 [142]

Answer:

C++ code explained below

Explanation:

Please note the below program has been tested on ubuntu 16.04 system and compiled using g++ compiler. This code will also work on other IDE's

-----------------------------------------------------------------------------------------------------------------------------------

Program:

-----------------------------------------------------------------------------------------------------------------------------------

//header files

#include<iostream>

//namespace

using namespace std;

//function defintion

void Output_Array_Info(int *array_ptr, int size)

{

//display all array elements

cout<<"Array elements are: "<<endl;

for(int i =0; i<size; i++)

{

cout<<*(array_ptr+i)<<endl;

}

//display address of each element

cout<<endl<<"memory address of each array elemnt is: "<<endl;

for(int i =0; i<size; i++)

{

cout<<array_ptr+i<<endl;

}

}

//start of main function

int main()

{

//pointer variables

int *pointer;

//an array

int numbers[] = { 5, 7, 9, 10, 12};

//pointer pointing to array

pointer = numbers;

//calculate the size of the array

int size = sizeof(numbers)/sizeof(int);

//call to function

Output_Array_Info(numbers, size);

return 0;

}

//end of the main program

8 0
3 years ago
8. Two 40 ft long wires made of differing materials are supported from the ceiling of a testing laboratory. Wire (1) is made of
san4es73 [151]

Answer:

Material K has a modulus of elasticity E=3.389× 10¹¹ Pa

Material H has a modulus of elasticity E=1.009 × 10⁹ Pa

Material K has higher value of modulus of elasticity than material H

Material K is stiffer.

Explanation:

Wire 1 material H

Length=L = 40 ft =12.192 m

Diameter= 3/8 in = 0.009525 m

Area= A= πr²,where r=0.009525/2 =0.004763

A=3.142*0.004763² =0.00007126 m²

Force, F= 225 lb=  225*4.45 =1001.25 N

Change in length =Δ L= 0.10 in = 0.00254

To find modulus of elasticity apply'

E=F*L/A*ΔL

E=1001.25*12.192/(0.004763*0.00254)

E= 1009027923.58 Pa

E=1.009 × 10⁹ Pa

For Wire 2 material K

Length=L= 40 ft =12.192 m

Diameter = 3/16 in = 0.1875 in = 0.004763 m

Area= πr² = 3.142 * (0.004763/2)² = 0.00000567154 m²

Force, F= 225 lb=  225*4.45 =1001.25 N

Change in length =Δ L= 0.25 in =0.00635 m

To find modulus of elasticity apply'

E=F*L/A*ΔL

E= (1001.25*12.192)/(0.00000567154 * 0.00635 )

E=338955422575 Pa

E=3.389× 10¹¹ Pa

Material  K has a greater modulus of elasticity

The material with higher value of E is stiffer than that with low value of E.The stiffer material is K.

8 0
3 years ago
A square silicon chip (k = 152 W/m·K) is of width 7 mm on a side and of thickness 3 mm. The chip is mounted in a substrate such
Harrizon [31]

Answer:

The steady-state temperature difference is 2.42 K

Explanation:

Rate of heat transfer = kA∆T/t

Rate of heat transfer = 6 W

k is the heat transfer coefficient = 152 W/m.K

A is the area of the square silicon = width^2 = (7/1000)^2 = 4.9×10^-5 m^2

t is the thickness of the silicon = 3 mm = 3/1000 = 0.003 m

6 = 152×4.9×10^-5×∆T/0.003

∆T = 6×0.003/152×4.9×10^-5 = 2.42 K

7 0
3 years ago
Zander worked at a pet shop in high school and during college began taking classes in veterinary medicine. To pay the bills duri
anastassius [24]
True.
To understand it better
First job : Pet shop
Second job : pizza place
The first job supports his career path he has experience.
The second job support life in making sure he gets to his career path/ does help financially for him to get there.
And it’s called career pathway.
3 0
2 years ago
Other questions:
  • The Review_c object has a lookup relationship up to the Job_Application_c object. The job_Application_c object has a master-deta
    7·1 answer
  • A ballistic pendulum consists of a 3.60 kg wooden block on the end of a long string. From the pivot point to the center‐of‐mass
    6·1 answer
  • When handling chemicals and solvents, technicians are recommended to
    10·2 answers
  • Give me an A please!!!¡!!!!¡
    5·1 answer
  • Technician A says that the distributor cap provides a connection point between the rotor and each individual cylinder plug wire.
    10·1 answer
  • What is a beam on a bridge? what does it do?
    6·1 answer
  • Answer the following questions about your own experience in the labor force.
    15·1 answer
  • What form of joining uses heat to create coalescence of the materials?
    7·1 answer
  • Additional scals apply to the
    9·1 answer
  • Engineers designed a motorcycle helmet from a long-lasting and safe material that protects the wearer from accidents and excessi
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!