% pascal_rowsum.m
%  Sum the entries in row N of Pascal's triangle.
%
n = input ( 'Enter the row to check: ' );

sum = 0;

for k = 0 : n

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

  sum = sum + value;

end

fprintf ( 'Row %d sums to %d and we expected a sum of %d.\n', n, sum, 2^n );
