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.
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