
anillo primo
Publicado por matias (1 intervención) el 18/05/2018 23:09:34
HACER UN PROGRAMA QUE DIGA QUE UN NUMERO ES ANILLO PRIMO O NO


Valora esta pregunta


0
clear all
numero=143256;
N=num2str(numero)
n=length(N);
if rem(n,2)==0
bol=0;
for i=1:n-1
sa=str2num(N(i))+str2num(N(i+1))
if isprime(sa)
else
bol=1;
end
end
sa=str2num(N(1))+str2num(N(i+1))
if isprime(sa)
else
bol=1;
end
end
if bol==0
disp('es anillo primo')
else
disp(' no es anillo primo')
end
>> anillo_primo
N =
'143256'
sa =
5
sa =
7
sa =
5
sa =
7
sa =
11
sa =
7
es anillo primo