Well, I like the solution with iterators the best as it showcase different aspects of your knowlege. Here is one in C#

static IEnumerable Fibonacci(double maxPosition)
{
double current = 1;
double previous = 0;
for (double i = 0; i < maxPosition; i++)
{
if (i > 1)
{
var oldCurrent = current;
current = current + previous;
previous = oldCurrent;
yield return current;
}
else
{
yield return i == 0 ? previous : current;
}}}







Answers and Comments