Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started