// Nombre de lancers n=10000; S=[0]; k=1; T=[1]; S=[]; Ecart=[]; for i=2:n do a=(-1)^grand(1,1,'uin',0,1); S(i)=S(i-1)+a; if S(i)==0 then T=[T i]; if length(T)>=2 then Ecart=[Ecart T(length(T))-T(length(T)-1)]; end end end //disp("S =") //disp(S) //disp("T =") //disp(T) //disp("Ecart :") //disp(Ecart) clf() plot2d([1:n],zeros(1,n),style=color('red')) plot2d([1:n],S)