public static int fibBuffer[] = new int [1000]; 
public static int fibTopDown(int n) 
{ 
   if ( n < 2 ) 
   { 
      return n; 
   } 
   else if ( fibBuffer[n] != 0 ) 
   { 
      return fibBuffer[n]; 
   } 
   else 
   { 
      fibBuffer[n] = fibTopDown(n-1) + fibTopDown(n-2); 
      return fibBuffer[n]; 
   } 
} 
