Going to offer myself for the slaughter here.
Have checked the other questions avail, and can't seem to find the cause of my IndexOutOfRange exception for the following code:
public static int fib2(int n)
{
int[] fibarray = new int[n];
if (n == 0) return 0;
fibarray[0] = 0;
fibarray[1] = 1;
for (int i = 2; i < n; i++)
{
fibarray[i] = fibarray[i - 1] + fibarray[i - 2];
}
return fibarray[n];
}
It's something really stupid I'm sure but it's driving me loopy (pun intended)...