function ret = tabfib(n)
  table = [0,1];
  for i = 3:(n+1)
    new = table(1) + table(2);
    table(1) = table(2);
    table(2) = new;
  endfor
  if (n < 1)
  	ret = 0;
  else	
     ret = table(2);
  endif
endfunction

%!assert (tabfib(0) == 0);
%!assert (tabfib(1) == 1);
%!assert (tabfib(2) == 1);
%!assert (tabfib(3) == 2);
%!assert (tabfib(4) == 3);
%!assert (tabfib(5) == 5);

