Need Help with Matlab

Thread Starter

JohnNN

Joined Jan 17, 2012
2
Hello,

Please helps. My professor is asking us to write a program using matlab to read in an integer and print the factors which divide into it. If the entered number is a prime number alert the user.

Please see if you could help.

Thank you
 

Thread Starter

JohnNN

Joined Jan 17, 2012
2
So far, this is what i have.. The loop gives me an error,, but i am not sure on how to fix it.

%Problem 2: This Program is to read in an integer and print out the factors
%which divide into it. If the entered value is a prime number, then alert
%the user.

value1=input('Input a Positive Integer = ');
a = 1:value1;
b = a.*isprime(a);
c = [1 b];
c=c(c>0);
if (value1 = c)
fprintf('Value is a prime number. Please enter another number.\n')
end
 
Top