login
a(n) = floor(n*H(n)) where H(n) is the n-th harmonic number, Sum_{k=1..n} 1/k (A001008/A002805).
6

%I #72 Oct 25 2023 06:18:31

%S 1,3,5,8,11,14,18,21,25,29,33,37,41,45,49,54,58,62,67,71,76,81,85,90,

%T 95,100,105,109,114,119,124,129,134,140,145,150,155,160,165,171,176,

%U 181,187,192,197,203,208,214,219,224,230,235,241,247,252,258,263,269

%N a(n) = floor(n*H(n)) where H(n) is the n-th harmonic number, Sum_{k=1..n} 1/k (A001008/A002805).

%C Floor(n*H(n)) gives a (very) rough approximation to the n-th prime.

%C a(n) is the integer part of the solution to the Coupon Collector's Problem. For example, if there are n=4 different prizes to collect from cereal boxes and they are equally likely to be found, then the integer part of the average number of boxes to buy before the collection is complete is a(4)=8. - Ron Lalonde (ronronronlalonde(AT)hotmail.com), Feb 04 2004

%D John D. Barrow, One Hundred Essential Things You Didn't Know You Didn't Know, Ch. 3, 'On the Cards', W. W. Norton & Co., NY & London, 2008, pp. 30-32.

%H Robert Israel, <a href="/A052488/b052488.txt">Table of n, a(n) for n = 1..10000</a>

%p for n from 1 to 100 do printf(`%d,`,floor(n*sum(1/k, k=1..n))) od:

%p # Alternatively:

%p A052488:= n -> floor(n*(Psi(n+1)+gamma));

%p seq(A052488(n),n=1..100); # _Robert Israel_, May 19 2014

%t f[n_] := Floor[n*HarmonicNumber[n]]; Array[f, 60] (* _Robert G. Wilson v_, Nov 23 2015 *)

%o (PARI) a(n) = floor(n*sum(k=1, n, 1/k)) \\ _Altug Alkan_, Nov 23 2015

%o (Magma) [Floor(n*HarmonicNumber(n)): n in [1..60]]; // _G. C. Greubel_, May 14 2019

%o (Sage) [floor(n*harmonic_number(n)) for n in (1..60)] # _G. C. Greubel_, May 14 2019

%o (Python)

%o from math import floor

%o n=100 #number of terms

%o ans=0

%o finalans = []

%o for i in range(1, n+1):

%o ans+=(1/i)

%o finalans.append(floor(ans*i))

%o print(finalans)

%o # _Adam Hugill_, Feb 14 2022

%o (Python)

%o from fractions import Fraction

%o from itertools import count, islice

%o def agen():

%o Hn = 0

%o for n in count(1):

%o Hn += Fraction(1, n)

%o yield (n*Hn.numerator)//Hn.denominator

%o print(list(islice(agen(), 60))) # _Michael S. Branicky_, Aug 10 2022

%o (Python)

%o from sympy import harmonic

%o def A052488(n): return int(n*harmonic(n)) # _Chai Wah Wu_, Oct 24 2023

%Y Cf. A001008, A002805, A006218, A060293.

%Y Cf. A001620, A073004.

%K easy,nonn

%O 1,2

%A Tomas Mario Kalmar (TomKalmar(AT)aol.com), Mar 15 2000

%E More terms from _James A. Sellers_, Mar 17 2000