#!/usr/bin/perl -w $P = 1; # probability of no common birthday print "\n This computes the probability that in a group of N people, at least two have the same birthday. \n\tEnter your choice of N here: "; $N = ; chomp($N); for ($K=0; $K < $N; $K++) { $P =$P*(1 - $K/365); $k = $K+1; $Q = sprintf("%.2f", 1 - $P); # probability of a common birthday print "With $k people, there is a probability $Q of a common birthday.\n"; # if (($k % 5) == 0) {print " $k $Q\n";} }