procedure euler (fct,sum,eps,tim); value eps,tim; integer tim;
     real procedure fct; real sum,eps;
     comment euler computes the sum of fct(i) for i from zero up to
     infinity by means of a suitably refined euler transformation. The
     summation is stopped as soon as tim times in succession the absolute
     value of the terms of the transformed series are found to be less than
     eps. Hence, one should provide a function fct with one integer argument,
     an upper bound eps, and an integer tim. The output is the sum sum. euler
     is particularly efficient in the case of a slowly convergent or
     divergent alternating series;
begin
   integer i,k,n,t; array m[0:15]; real mn,mp,ds;
   i ≔ ; t ≔ ; m[0] ≔ ct(0); sum ≔ [0]/2;
   nextterm: i ≔ +1; mn ≔ ct(i);
   for k ≔  step 1 until n do
      begin mp ≔ mn+m[k])/2; m[k] ≔ n;
         mn ≔ p
      end means;
   if (abs(mn)<abs(m[n])) ∧ (n<15) then begin
      ds ≔ n/2; n ≔ +1; m[n] ≔ n
   end accept
   else ds ≔ n;
   sum ≔ um+ds;
   if abs(ds) < eps then t ≔ +1 else t ≔ ;
   if t < tim then goto nextterm
end euler;