New Sequence from wrong Comment in A083088

Robert Israel israel at math.ubc.ca
Sat Jan 5 00:55:46 CET 2008



On Sat, 5 Jan 2008, Rainer Rosenthal wrote:

> -------
> Harmonic := n -> expand(Psi(n+1))+gamma;
> a := proc(n) local erg,m; erg := 0; for m to
> infinity do if Harmonic(n-1+m)-Harmonic(n-1) > 1
> then erg := m-1; break; fi; od; return erg; end;
> seq(a(n),n=1..50);

This Maple program is very inefficient because you
are recalculating both Harmonic(n-1+m) and Harmonic(n-1)
for each m.  Better and simpler would be

a := proc(n) local t, m; t:= 0; for m from n do t:= t+1/m;
if t > 1 then return m-n; end if; end do; end proc;

Robert Israel                                israel at math.ubc.ca
Department of Mathematics        http://www.math.ubc.ca/~israel 
University of British Columbia            Vancouver, BC, Canada





More information about the SeqFan mailing list