Answer:
function pf=primeFactor(n)
%Print the number of 2s that divide n
pf=[];
while mod(n,2) == 0
pf=[pf,2];
n = n/2;
end
% n must be odd at this point. So we can skip
% one element (Note i = i +2)
for i=3:sqrt(n)
% While i divides n, print i and divide n
while mod(n, i) == 0
pf=[pf,i];
n = n/i;
end
end
% This condition is to handle the case when n
% is a prime number greater than 2
if (n > 2)
pf=[pf,n];
end
end
Explanation: