Hi guys. I will explain the problem I have in my own words.

I have to make a program using the Fibonacci numbers, in which the user inputs a number of days and the original size a green crud population, and every 5 days the population changes by fibonacci numbers. I went to the professor's office, and he gave me some hints, that I must divide the number of days entered by 5, and that is the number of iterations that I should run the loop. 1st of all I really dont know how to do a loop in which I run several times for that asked... and the other problem is that the loop must be made in a function, and I have never done a function before and I have some problems on the compiler, so if you guys could help me out.

The professor also said that to calculate the fibonacci number using a certain amount of time the formula I should use for my function is:

fib(iter) = (fib(iter - 1) + fib(iter - 2))

BTW, fib(0) = sizeCrud, fib(1) = sizeCrud... and then I use that formula

So the problem I have is that I should do a loop that repeats 'iter' amount of times, and also it should be made on a function, and I really do not know how!!!

I will put my code in here so you guys can help me.

```
#include<iostream>
using namespace std;
double fib(int iter);
//Calcules the size of the green crud population after different 'iter' amount of time
int main()
{
double sizeCrudPopulation, finalSize;
int numberDays, iter;
char ans;
do
{
cout << "We are about to help you find the size in pounds of a ";
cout << "green crud population after a certain amount of days.\n";
cout << "Enter the initial size of the green crud population in pounds:\n";
cin >> sizeCrudPopulation;
cout << "Now enter the number of days to see the size of the green crud:\n";
cin >> numberDays;
iter = numberDays / 5;
finalSize = fib(iter);
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout << "The size of the green crud population after " << numberDays;
cout << " days is " << finalSize << " pounds.\n";
cout << endl;
cout << "Do you want to run this program again? Press 'Y' for yes, or 'N' for no.\n";
cin >> ans;
} while (ans == 'Y' || ans == 'y');
cout << "Have a nice day!\n";
return 0;
}
double fib(int iter)
{
while (iter >= 0)
{
while (iter >= 0)
{
fib(0) = sizeCrudPopulation;
}
while (iter >= 1)
{
fib(1) = sizeCrudPopulation;
}
while (iter >= 2)
fib(iter) = (fib(iter - 1) + fib(iter - 2));
}
}
```

This code is wrong... because I am not using a loop that repeats iter amount of times... and even my function is bad... help please!! and BTW, remember that Im a beginner, only use int main(), not other strange things to me