function p5 ( )

  fprintf ( 1, '\n' );
  fprintf ( 1, 'P5:\n' );
  fprintf ( 1, '  In a party of N people, estimate the probability that\n' );
  fprintf ( 1, '  at least two people will share a birthday?\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '   N    Prob\n' );
  fprintf ( 1, '\n' );
  for n = 1 : 30
    prob = party_prob ( n );
    fprintf ( 1, '  %2d  %8.4f\n', n, prob );
  end

  return
end
function prob = party_prob ( n )
  m = 10000;
  prob = 0.0;
  for i = 1 : m
    prob = prob + party ( n );
  end
  prob = prob / m;
  return
end
function value = party ( n )
  b = randi ( [ 1, 365 ], 1, n );
  u = unique ( b );
  value = ( length ( u ) < length ( b ) );
  return
end
