function sierpinski(rez, iter)
% radimo rez+iter iteracija od cega se prvih iter preskace a narednih rez
% crta
% sierpinski(10000,1000)
pts = zeros(rez,2);
x = 1;
y = 1;
    hold on
for j = 1:rez+iter
        p = rand(1);
        if p <= 1/3
            xn = x/2;
            yn = y/2;
            x = xn;
            y = yn;
            plot(xn,yn,'.r')
        elseif p <= 2/3
            xn = (2*x+1)/4;
            yn = (y+1)/2;
            x = xn;
            y = yn;
            plot(xn,yn,'.b')
        elseif p <= 1
            xn = (x+1)/2;
            yn = y/2;
            x = xn;
            y = yn;
            plot(xn,yn,'.k')
        end
    pts(j,1) = x;
    pts(j,2) = y;
end%j

xs = pts(iter:end,1);
ys = pts(iter:end,2);
%plot(xs,ys,'.r')
