% pascal_triangle.m
%  Compute rows 0:N of Pascal's triangle.
%
nmax = input ( 'Enter the value of NMAX: ' );

for n = 0 : nmax

  for k = 0 : n

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

    fprintf ( ' %3d', value );

  end

  fprintf ( '\n' );

end
