% integer_sum.m
%
%  Sum the integers from 1 to N.
%  Compare with a formula.
% 
n = input ( 'Enter the value of N:' );

s1 = 0;
for i = 1 : n
  s1 = s1 + i;
end

s2 = n * ( n + 1 ) / 2;

fprintf ( '  Sum = %d, Formula = %d\n', s1, s2 );
