Computer Science, asked by swethachowdary845, 9 months ago

The Environmental Eco Club has discovered a new Amoeba that grows in the order of a Fibonacci series every month. They are exhibiting this amoeba in a national conference. They want to know the size of the amoeba at a particular time instant. If a particular month’s index is given, write a program to display the amoeba’s size. For Example, the size of the amoeba on month 1, 2, 3, 4, 5, 6,... will be 0, 1, 1, 2, 3, 5, 8.... respectively.

Answers

Answered by parthik1999
22

Answer:

#include <iostream>  

using namespace std;  

int main()  

{  

int n1=0,n2=1,n3,i,number;    

 

std::cin>>number;    

for(i=2;i<number;++i)  

{    

 n3=n1+n2;    

 n1=n2;    

 n2=n3;    

}  

std::cout<<n3;

   

}

Explanation:

Answered by ankhidassarma9
0

Answer:

#include<iostream>

using namespace std;

int fib(int n)

{

int f[n+2];

int d,i;

f[0]=0;

f[1]=1;

cout << " Month number : " << f[0] << " ..... Size of the amoeba... " << f[0]<< endl;

cout << " Month number : " << f[1] << " ..... Size of the amoeba... " << f[1]<< endl;

 for(i=2; i<=n; i++)

{

  f[i]=f[i-1] + f[i-2];

cout << " Month number : " << i << " ..... Size of the amoeba... ";

cout<< f[i]<<endl;

}

d=f[n-1];

 return d;

}

int main()

{

int n;

cout<<" enter the number of months:";

std::cin>>n;

fib(n);

}

Explanation:

Input :  enter the number of months:6

Output:

Month number : 0 ..... Size of the amoeba... 0

Month number : 1 ..... Size of the amoeba... 1

Month number : 2 ..... Size of the amoeba... 1

Month number : 3 ..... Size of the amoeba... 2

Month number : 4 ..... Size of the amoeba... 3

Month number : 5 ..... Size of the amoeba... 5

Month number : 6 ..... Size of the amoeba... 8

Similar questions