×
Get Full Access to C++ For Everyone - 2 Edition - Chapter 4 - Problem P4.18
Get Full Access to C++ For Everyone - 2 Edition - Chapter 4 - Problem P4.18

×

# The Fibonacci numbers are defined by the sequencefff f f n n n121 211=== + Reformulate

ISBN: 9780470927137 356

## Solution for problem P4.18 Chapter 4

C++ for Everyone | 2nd Edition

• Textbook Solutions
• 2901 Step-by-step solutions solved by professors and subject experts
• Get 24/7 help from StudySoup virtual teaching assistants

C++ for Everyone | 2nd Edition

4 5 1 395 Reviews
31
4
Problem P4.18

The Fibonacci numbers are defined by the sequencefff f f n n n121 211=== + Reformulate that asfold1 = 1;fold2 = 1;fnew = fold1 + fold2;After that, discard fold2, which is no longer needed, and set fold2 to fold1 and fold1 tofnew. Repeat fnew an appropriate number of times.Implement a program that computes the Fibonacci numbers in that way.

Step-by-Step Solution:
Step 1 of 3

BE 1500 – Fall 2016 HW 4 Due: 9/29/16 (1:30 P.M.) 1. Write a function file that determines the following sum (for all odd n from 1 to 11) using a for loop. The starting point, ending point, and increment should be input to the function file. 2n+2 y=Σ n−2 function [sum1]=HW5P1(a,b,c) sum1=0; for i=a:b:c sum1=sum1+(2^(i+2))/(i-2); end 2 points  0.25 for correct function header  0.25 for comments  0.5 for initializing sum  0.5 for correct for statement  0.5 for correct sum1 statement 2. The geometric mean of a set of number1 x througn x is defined as the nth root of the product of numbers: 1/n Geometric mean = (x1*2 …n ) Write a script that will accept an arbitrary number of positive input values and calculate the average and the geometric mean of the numbers. Use a while loop to get the input values and terminate the input if the user inputs a negative number. Test your program by calculating the average and geometric mean of the four numbers 10, 5, 2, and 5. i=1; x=input('x= '); sum1=0; prod1=1; while x>0 sum1=sum1+x; prod1=prod1*x; x=input('x= '); i=i+1; end final_ave=sum1/(i-1) final_geom=prod1^(1/(i-1)) 2 points  0.25 for comments  0.25 for x=input before loop and within loop  0.25 for initializing i 

Step 2 of 3

Step 3 of 3

##### ISBN: 9780470927137

The answer to “The Fibonacci numbers are defined by the sequencefff f f n n n121 211=== + Reformulate that asfold1 = 1;fold2 = 1;fnew = fold1 + fold2;After that, discard fold2, which is no longer needed, and set fold2 to fold1 and fold1 tofnew. Repeat fnew an appropriate number of times.Implement a program that computes the Fibonacci numbers in that way.” is broken down into a number of easy to follow steps, and 59 words. This full solution covers the following key subjects: . This expansive textbook survival guide covers 10 chapters, and 515 solutions. The full step-by-step solution to problem: P4.18 from chapter: 4 was answered by , our top Engineering and Tech solution expert on 03/08/18, 08:39PM. This textbook survival guide was created for the textbook: C++ for Everyone , edition: 2. C++ for Everyone was written by and is associated to the ISBN: 9780470927137. Since the solution to P4.18 from 4 chapter was answered, more than 416 students have viewed the full step-by-step answer.

## Discover and learn what students are asking

Chemistry: The Central Science : Molecular Geometry and Bonding Theories
?In the hydrocarbon (a) What is the hybridization at each carbon atom in the molecule? (b) How many \(

#### Related chapters

Unlock Textbook Solution