function s_n=priklad4(n)
%s_n=priklad4(n)
%vypocte castecny soucet s_n rady 4 * (1 - 1/3 + 1/5 - 1/7 + 1/9 - ... )
%a_k = 4 * (-1)^{k+1} / (2k - 1) 

s_n = 0;
for k = 1 : n
    s_n = s_n + (-1)^(k+1) / (2*k - 1);
end
s_n = 4 * s_n;

fprintf('Soucet prvnich %d clenu rady je roven %f.\n', n, s_n)

% konec