Need Help with Matlab

Discussion in 'Homework Help' started by JohnNN, Jan 17, 2012.

  1. JohnNN

    Thread Starter New Member

    Jan 17, 2012
    2
    0
    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
     
  2. guitarguy12387

    Active Member

    Apr 10, 2008
    359
    12
    What have you tried so far?
     
  3. JohnNN

    Thread Starter New Member

    Jan 17, 2012
    2
    0
    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
     
Loading...