login
Least k such that Sum_{i=n..k} 1/i >= n.
0

%I #27 Feb 07 2022 01:47:48

%S 1,11,51,192,669,2222,7135,22374,68916,209348,628916,1872269,5531641,

%T 16238866,47410139,137758585,398617683,1149205715,3302324374,

%U 9461757569,27038402095,77082571383,219276117983,622541323482,1764242459656

%N Least k such that Sum_{i=n..k} 1/i >= n.

%H Northwolves, <a href="http://blog.csdn.net/northwolves/archive/2009/11/20/4844754.aspx">Harmonic number sum</a>

%e 1/2 + 1/3 + ... + 1/10 < 2, but 1/2 + 1/3 + ... + 1/11 >= 2, so a(2) = 11.

%t a[n_] := k /. FindRoot[Sum[1/i, {i, n, k}] == n, {k, n*E^n}, WorkingPrecision -> 32] // Ceiling; Table[a[n], {n, 1, 25}] (* _Jean-François Alcover_, Jun 08 2013 *)

%o (VBA)

%o Sub Harmonic_number_sum()

%o Dim s As Double, i As Long, j As Long, n As Long

%o For n = 1 To 15

%o s = 0

%o For i = n To 1000000000

%o s = s + 1 / i

%o If s >= n Then Exit For

%o Next

%o Debug.Print "a(" & n & ")=" & i:

%o Next

%o End Sub

%o (PARI) a(n)=my(k=n,s);while((s+=1./k)<n,k++);k \\ _Charles R Greathouse IV_, Jun 17 2013

%Y Cf. A004080, A002387

%K easy,nice,nonn

%O 1,2

%A _Zhining Yang_, Nov 20 2009

%E a(18)-a(25) from _Donovan Johnson_, Jun 19 2010

%E Example edited by _Jon E. Schoenfield_, Dec 20 2014