% pascal_rowbar.m
%  Plot the entries in row N of Pascal's triangle.
%
n = input ( 'Enter the row to plot: ' );

value_list = [];

for k = 0 : n

  if ( k == 0 )
    value = 1;
  else
    value = value * ( n + 1 - k ) / k;
  end

  value_list = [ value_list, value ];

end

bar ( 0:n, value_list );
title ( 'Number of ways of getting K heads in N tosses' );
xlabel ( '<-- K = number of heads -->' );
ylabel ( '<-- Count -->' );
