With replacement, P(X=k)=(m−1m)k−11m
for 1≤k<n
and P(X=n)=(m−1m)n−11m+(m−1m)n.
In the case of sampling without replacement, since all orderings of the
passwords sampled by the hacker are equally likely, P(hacker samples k passwords)=1m
for 1≤k<n,
and P(hacker samples n passwords)=1m+m−nm.