#!/usr/bin/perl -w

# In an office, say your personal code to use the photo copy machine
# is the last four digits of your social security number.  
#a).  If 100 people share that copier, what is the probability that at
#     least two people have the same code?
# b). Same question with 150 people.

print "\n This computes the probability that in a group of N people, at least
two have the same last 4 digits of their Social Security Numbers.  
\n\tEnter your choice of N here:  ";
$N = <STDIN>;
chomp($N);                                                                   
$P = 1;	

for ($K=0; $K < $N; $K++) {
	$P =$P*(1 - $K/10000);
	$k = $K+1;
	$Q = sprintf("%.2f", 1 - $P);	# probability of same last 4 SSN digits
##print "With $k people, there is a probability  $Q of same last 4 SSN digits.\n";
	if (($k % 5) == 0) {print "  $k   $Q\n";}
}
