I need help with this with MATLAB CODE Write a dimesiesprimo
I need help with this with MATLAB CODE:
Write a \"dimesiesprimo\" function that receives a number (integer greater than 1) and return a 1 if it is prime, a 0 otherwise. Present PrtScs and desktop tests for: 2, 3, 12, 13. Present only PrtScs for: 4283, 5329.
Thanks a lot!
Solution
n = input(\'Enter value of n: \')
m = 2; % initialise factor to test
for m = 2:floor(sqrt(n))
if mod(n,m) == 0 %m is a factor of n
disp(\'n is not prime\') & return
end
end;
This is raw MATLAB program for use case.
