MATLAB An isolated prime is a prime number p such that neith
MATLAB
An isolated prime is a prime number, p, such that neither p - 2 nor p + 2 is prime. For example, 47 is an isolated prime since 45 and 49 are both not primes. Write a computer program that finds all the isolated primes between 50 and 100. You can use the built-in function isprime.
Solution
clear
j=1;
for i=50:1:100;
if(isprime(i))
if((isprime(i+2))==0)
if((isprime(i-2)==0))
x(j)=i;
j=j+1;
end;
end;
end;
end
ans:
x =
53 67 79 83 89 97
