In MATLAB the isprime function is used to check whether or
Solution
1)
isprime(A) returns an array the same size as A containing logical true (1) for the elements of A which are prime, and logical false (0) otherwise. A must contain only positive integers.
Examples
c = [2 3 0 6 10]
c =
2 3 0 6 10
isprime(c)
ans =
1 1 0 0 0
a) function f = checkforprimeV2 (n)
divider = n;
for ii = 1:length(n)
counter= 0;
check = n(ii) / 2;
check2 = floor(check);
if check ~= check2
while divider(ii) > 1 && counter <= 1 ,
divider(ii) = (divider(ii) - 1);
p = n(ii) / divider(ii);
if p == floor(p)
counter = counter + 1;
end
end
else
counter = 2;
f(ii) = 0;
end
if counter > 1
f(ii) = 0;
else
f(ii) = 1;
end
end
end
b)
You have to choose 2 random prime numbers, it\'s right?
I think you can do it in this way:
p=[4 4];
for i=1:2
while isprime(p(i))==0
p(i)=randint(1,1,1000);
end
end

