You are on page 1of 4

# clear all;

clc;
t=1;
d=1;
for c=1:n
x=input('ingrese un numero: ')
if mod(x,2)==0
t=x/2
else
d=x*3+1
end

end
disp(['suma de pares ',num2str(t)]);
disp(['suma de impares ',num2str(d)]);

mal clc
clear all
n1=input('Primer numero :');
n2=input('Segundo numero :');
d=2;
mcd=1;
mcm=1;
while d<=n1 & d<=n2
if rem(n1,d)==0 & rem(n2,d)==0
mcd=mcd*d;
n1=n1/d;
n2=n2/d;
disp(['el maximo comun divisor es: ',num2str(mcd)]);
elseif rem(n1,d)==0 | rem(n2,d)==0
mcm=mcm*d;
if rem(n1,d)==0
n1=n1/d;
end
if rem(n2,d)==0
n2=n2/d;
end
disp(['el minimo comun multiplo es: ',num2str(mcm)]);

else
d=d+1;
end
end

________________________________________--
clc
clear all
n1=input('Primer numero :');
n2=input('Segundo numero :');
d=2;
mcd=1;
mcm=1;
while d<=n1 & d<=n2
if rem(n1,d)==0 & rem(n2,d)==0
mcd=mcd*d
n1=n1/d;
n2=n2/d;
else
d=d+1;
end
end
while n1~=1 | n2~=1
if rem(n1,d)==0 | rem(n2,d)==0
mcm=mcm*d
if rem(n1,d)==0
n1=n1/d;
end
if rem(n2,d)==0
n2=n2/d;
end
else
d=d+1;
end
end
mmmmmmmmmmmmmmmmmm clc
clear all
n1=input('Primer numero :');
n2=input('Segundo numero :');
d=2;
mcd=1;
mcm=1;
while d<=n1 & d<=n2
if rem(n1,d)==0 & rem(n2,d)==0
mcd=mcd*d
n1=n1/d;
n2=n2/d;
else
d=d+1;
end
end
fprintf('El m.c.d. es : %d ',mcd);
while n1~=1 | n2~=1
if rem(n1,d)==0 | rem(n2,d)==0
mcm=mcm*d
if rem(n1,d)==0
n1=n1/d;
end
if rem(n2,d)==0
n2=n2/d;
end
else
d=d+1;
end
end
fprintf('El m.c.m. es : %d ',mcm);
bbbbbbbbbbbb clc
clear all
n1=input('Primer numero :');
n2=input('Segundo numero :');
n3=input('tercer numero : ');
d=3;
mcd=1;
mcm=1;
while d<=n1 & d<=n2 & d<=n3 % para maximo comun divisor
if rem(n1,d)==0 & rem(n2,d)==0 & rem(n3,d)==0
mcd=mcd*d
n1=n1/d;
n2=n2/d;
n3=n3/d;
else
d=d+2;
end
end
while n1~=1 | n2~=1 | n3~=1 %para minimo comun multiplo
if rem(n1,d)==0 | rem(n2,d)==0 | rem(n3,d)==0
mcm=mcm*d
if rem(n1,d)==0
n1=n1/d;
end
if rem(n2,d)==0
n2=n2/d;
end
if rem(n3,d)==0
n3=n3/d;
end
else
d=d+2;
end
end
fprintf('El m.c.d. es : %d ',mcd);
fprintf('El m.c.m. es : %d ',mcm);
mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm clc
clear all
n=input('Primer el numero n :');
a=input('Segundo el numero a :');
b=input('tercer el numero b : ');
s=0;
f=1;
for i=0:n

if rem(i,2)==0
f=f*(i+1);
s=(s+f)/(a+b*i);
else
f=f*(i+1);
s=(s-f)/(a+b*i);
end
end
esta biennnnnnnnnnnnnnnnnnnnnnnnnnnn okkkkkkkkkkkkkk

wil clc
clear all
n=input('Primer el numero n :');
a=input('Segundo el numero a :');
b=input('tercer el numero b : ');
s=0;
f=1;
for i=0:n

if rem(i,2)==0
f=f*(i+1);
s=s+f/(a+b*i);
else
f=f*(i+1);
s=s-f/(a+b*i);
end
end