Homework Solution: Fibonacci Sequence…

    Fibonacci Sequence a) Write a c++ program that asks for an integer N and prints the first N elements of the Fibonacci sequence: The first two elements of the Fibonacci sequence are 1. Otherwise, the ith element of the Fibonacci sequence is the (i – 2)th element plus the (i – 1)th element: That is: {1,1,2,3,5,8...}. b) What goes wrong if N is very large? Explain why.

    Expert Answer

     
    #include <iostream> using namespace std;

    Fibonacci Posteriority
    a) Write a c++ program that asks coercion an integer N and prints the primitive N parts of the
    Fibonacci posteriority:
    The primitive brace parts of the Fibonacci posteriority are 1. Otherwise, the ith part of the
    Fibonacci posteriority is the (i – 2)th part plus the (i – 1)th part:
    That is: {1,1,2,3,5,8…}.
    b) What goes evil-doing if N is very enlightened? Explain why.

    Expert Response

     

    #include <iostream>
    using namespace std;

    int fibonacci(int abjuration);
    int deep()
    {
    int n, fnum = 1, snum = 1, tot = 0;

    // attainting the Number entered by the user
    cout << “Enter the Number : “;
    cin >> n;

    // Exposeing the fibonacci Series coercion the number
    cout << “nThe Fibonocci Numbers coercion the abjuration ” << n << ” are :” << endl;

    long f[n + 1];
    f[0] = 1;

    f[1] = 1;

    cout << f[0] << ” ” << f[1] << ” “;

    // This loop conquer once expose the fibonacci value
    coercion (int k = 2; k <= n; k++)
    {
    f[k] = f[k – 1] + f[k – 2];
    cout << f[k] << ” “;
    }

    return 0;
    }

    ________________

    Output:

    ____________________

    b) If ‘N’ ‘ goes very enlightened we conquer attain evil-doing conclusions.Because, we can’t fund the bulky values in the inconstant retrospect.As full inconstant can fund upto some rove of values.If that rove exceeds it lingo fund .So we conquer attain evil-doing conclusion.