OFFSET
0,3
COMMENTS
a(n) is the minimum size of a hash table such that for n items the probability of collision is smaller than 50%.
The probability that, in a set of n randomly chosen people, some pair of them will have the same birthday is less than 50% if there are at least a(n) days in a year.
LINKS
FORMULA
a(n) = A072829(n)+1 for n>1.
MAPLE
a:= proc(n) option remember; local m; Digits:= 20;
if n<2 then m:= n else for m from 2*a(n-1)-a(n-2) do
if n*log(0.0+m)<log(2.0)+lnGAMMA(1.0+m)-lnGAMMA(1.0+m-n)
then break fi od fi; m
end:
seq(a(n), n=0..55);
MATHEMATICA
a[n_] := a[n] = If[n < 2, n, Module[{m}, For[m = 2*a[n-1] - a[n-2], True, m++, If[n*Log[m] < Log[2.`20.] + LogGamma[1.`20. + m] - LogGamma[1.`20. + m - n], Return[m]]]]];
a /@ Range[0, 55] (* Jean-François Alcover, Apr 19 2021, after Alois P. Heinz *)
PROG
(Python)
from math import comb, factorial
def A308699(n):
f = factorial(n)
def p(m): return comb(m, n)*f<<1
kmin, kmax = n-1, n
while p(kmax) <= kmax**n: kmax<<=1
while kmax-kmin > 1:
kmid = kmax+kmin>>1
if p(kmid) > kmid**n:
kmax = kmid
else:
kmin = kmid
return kmax # Chai Wah Wu, Jan 21 2025
CROSSREFS
KEYWORD
nonn,changed
AUTHOR
Alois P. Heinz, Jun 17 2019
STATUS
approved