Question: Need to debug this matlab code so that it displays all prime factors of an inputed number n. Including repeats i.e n=12 output= 2 2

Need to debug this matlab code so that it displays all prime factors of an inputed number n. Including repeats i.e n=12 output= 2 2 3

n == input('Enter a positive, whole number n: ');

divisor = 1;

fprintf('Prime factors: ');

while n < 1

if mod(n,divisor) == 0

fprintf('%d ',n)

n/divisor;

else

divisor = divisor*1;

end

end

disp(' ')

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Lets debug and correct the given MATLAB code so that it accurately identifies and displays all prime ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!