Vous êtes sur la page 1sur 2

%EJRECICIO #2

fprintf('\n EJERCICIO 2: "Sucesion de Fibonocci" \n');


a(1)=0;
a(2)=1;
for i=1:18
a(i+2)=a(i+1)+a(i);
end
R2=[1:20;a];
fprintf('%5.2i %5.2i \n',R2)

%EJERCICIO # 4
fprintf('\n EJERCICIO 4: "Aproximaxion de PI" \n');
k=1;
for m=[100 100000 10000000]
Api(k)=2;
for n=1:m
Api(k)=Api(k)*((2*n)^2)/((2*n)^2-1);
end
k=k+1;
end
m=[100 100000 10000000];
R=[m;Api];
fprintf('%5.0i \t\t\t %5.15f \n',R);
%EJERCICIO # 6
fprintf('\n EJERCICIO 6: "Primos Gemelos " \n')
c=1;
for j=10:500
cont=0;
for k=2:j-1
if (mod(j,k)==0)
cont=cont+1;
end
end
if(cont==0)
primos(c)=j;
c=c+1;
end
end
c2=1;
for i=1:length(primos)-1
if(primos(i+1)-primos(i)==2)
PG(c2,1)=primos(i+1);
PG(c2,2)=primos(i);
c2=c2+1;
end
end
PG
% EJERCICIO #8
fprintf('\n EJERCICIO #8: "Planificacion Aleatoria de Partidos" \n')
E(1)=1+floor(rand()*11.9);
for i=2:12
bol=true;
while (bol==true)
bol=false;
ax=floor(1+rand()*11.9);
for j=1:i-1
if(ax==E(j))
bol=true;
break;
end
end
if bol==false
E(i)=ax;
end
end
end
fprintf('%5.2i %5.2i \n',E(1:6),E(7:12))

Vous aimerez peut-être aussi