Está en la página 1de 2

clc;

clear all
close all
disp("Programa que calcula si tres numeros son PESI");
a=input("\nIngrese primer numero:");
b=input("\nIngrese segundo numero:");
c=input("\nIngrese tercer numero:");
contador=0;
cuenta=0;
cantidad=0;
if a>b && b>c
menor=c;
mayor=a;
medio=b;
elseif a>c && c>b
menor=b;
mayor=a;
medio=c;
elseif b>a && a>c
menor=c;
mayor=b;
medio=a;
elseif b>c && c>a
menor=a;
mayor=b;
medio=c;
elseif c>a && a>b
menor=b;
mayor=c;
medio=a;
elseif c>b && b>a
menor=a;
mayor=c;
medio=b;
end
for i=1:medio
if mod(medio,i)==0
if mod(mayor,i)==0
cuenta=cuenta+1;
end
end
end
if cuenta==1
fprintf("\nEl %d y el %d son PESI",medio,mayor)
end
for i=1:menor
if mod(menor,i)==0
if mod(mayor,i)==0
contador=contador+1;
end
end
end
if contador==1
fprintf("\nEl %d y el %d son PESI",menor,mayor)
end

for i=1:menor
if mod(menor,i)==0
if mod(medio,i)==0
cantidad=cantidad+1;
end
end
end
if cantidad==1
fprintf("\nEl %d y el %d son PESI",medio,menor)
end

También podría gustarte