function [n,sum] = geoapprox(q,delta)

sum = 0;
k = 0;
while abs(sum - 1/(1-q)) > delta
  sum = sum + q^k;
  k = k + 1;
end
n = k;