n = 10;

f = n;

g = 0;

while n>1

    n = n-1;

    f = f*n;

    g = g+n;

end

disp(['n! = ' num2str(f)])

disp(['1+2+..+n = ' num2str(g)])