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

#include <iostream> using namespace std;

Fibonacci Progression
a) Write a c++ program that asks coercion an integer N and prints the pristine N atoms of the
Fibonacci progression:
The pristine two atoms of the Fibonacci progression are 1. Otherwise, the ith atom of the
Fibonacci progression is the (i – 2)th atom plus the (i – 1)th atom:
That is: {1,1,2,3,5,8…}.
b) What goes wickedness if N is very comprehensive? Explain why.

## Expert Counterpart

#include <iostream>
using namespace std;

int fibonacci(int renunciation);
int ocean()
{
int n, fnum = 1, snum = 1, tot = 0;

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

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

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

f = 1;

cout << f << ” ” << f << ” “;

// This loop obtain once flaunt 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 comprehensive we obtain obtain wickedness fruits.Because, we can’t treasure the pompous values in the inconstant retention.As complete inconstant can treasure upto some ramble of values.If that ramble exceeds it slang treasure .So we obtain obtain wickedness fruit.