n = 0; sum_x = 0; sum_x2 = 0;

t = input('first value: ');

while t >= 0
   n = n + 1;
   x(n) = t;
   t = input('Next value: ');
end

for ii = 1:n
   sum_x = sum_x + x(ii);
   sum_x2 = sum_x2 + x(ii)^2;
end

x_bar = sum_x/n;
sd = sqrt((n*sum_x2 - sum_x^2)/(n*(n-1)));

fprintf('Mean: %f\n', x_bar);
fprintf('SD:   %f\n', sd);
fprintf('Count:%f\n', n);

