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

x = input('first value: ');

while x >= 0
   n = n + 1;
   sum_x = sum_x + x;
   sum_x2 = sum_x2 + x^2;
   x = input('Next value: ');
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:%d\n', n);

