function match ( n, N )

%*****************************************************************************80
%
%% match() computes the probablity of a coin flipping match.
%
%  Discussion:
%
%    This code computes the probability that N people,
%    flipping fair coins n times, will each get the same
%    number of heads.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    29 January 2018
%
%  Author:
%
%    Paul Nahin
%
%  Reference:
%
%    Paul Nahin,
%    Dueling Idiots and Other Probability Puzzlers,
%    Princeton, 2012,
%    ISBN: 978-0691155005.
%
%  Input:
%
%    integer n, the number of times a person flips a coin.
%
%    integer N, the number of people.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'match()\n' );
  fprintf ( 1, '  Compute the probability that N people,\n' );
  fprintf ( 1, '  flipping fair coins n times, will each get the same\n' );
  fprintf ( 1, '  number of heads.\n' );

  summation = 0;
  for k = 0 : n
    bc = binomial ( n, k );
    summation = summation + ( bc ) ^ N;
  end
  summation = summation / ( 2 ^ ( N * n ) );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Match probability is %g\n', summation );

  return
end
