Fibonacci number. In mathematics, the Fibonacci numbers area sequence of numbers
ID: 3609095 • Letter: F
Question
Fibonacci number. In mathematics, the Fibonacci numbers area sequenceof numbers named after Leonardo of Pisa, known as Fibonacci. Thefirst number of the
sequence is 0, the second number is 1, and each subsequent numberis equal to the sum of
the previous two numbers of the sequence itself, yielding thesequence 0, 1, 1, 2, 3, 5, 8,
etc. In mathematical terms, it is defined by the followingrecurrence relation:
In Function 2, let’s call this function fib(int n). The inputto the function is variable n,
and the function returns an integer. For examples, given n as 0,fib(0) returns 0; and
given n as 4, fib(4) returns 3.
In main( ) function, you need to do the following:
5. produce a sequence of 20 Fibonacci numbers and output thesenumbers on screen
and write these numbers into “.txt”
In step 2, main ( ) function needs to call function 1 (gcd).In step 5, main( )
function needs to call function 2 (fib).
Example of" txt" should look like this, if eight numbers in Fibsequence,
0 1 1 2 3 5 8 13 21
Notice that your program is to produce 20 Fib numbers.
Explanation / Answer
please rate - thanks I don't understand this In step 2,main ( ) function needs to call function 1 (gcd). In step 5, main() function needs to call function 2 (fib). #include #include int fib(int); int main() { int first,second,next,i,fibn; int n=20; ofstream output; output.open("fib.txt"); for(i=0;iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.