Full solution, if this is what you want
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication
{
class Program
{
static IEnumerable<long> fibs = Enumerable.Empty<long>();
static int count, fromIndex, toIndex;
static void Main(string[] args)
{
while (true)
{
Generate();
Console.Write(string.Format("Enter index range between 0 and {0}\n", count));
Console.Write("Enter first index : ");
fromIndex = int.Parse(Console.ReadLine());
Console.Write("Enter last index : ");
toIndex = int.Parse(Console.ReadLine());
GenerateSubset(fromIndex, toIndex);
}
}
public static void Generate()
{
int i;
long f1 = 0, f2 = 1, f3 = 0;
Console.Write("Enter the Limit : ");
count = int.Parse(Console.ReadLine());
fibs = fibs.Concat(new[] { f2 });
Console.Write("Full sequence :\n");
Console.WriteLine(f2);
for (i = 0; i < count; i++)
{
f3 = f1 + f2;
fibs = fibs.Concat(new[] { f3 });
Console.WriteLine(f3);
f1 = f2;
f2 = f3;
}
}
static public void GenerateSubset(int fromIndex, int toIndex)
{
for (int i = fromIndex; i <= toIndex; i++)
{
Console.WriteLine(fibs.ElementAt(i));
}
Console.WriteLine("\n");
}
}
}
Program screenshot:
http://imgur.com/ogER8oQ