Using MATLAB write a function that takes a relatively small(less than 100 billion) positive integer input and outputs theprime factorization of that integer using as few built-in functionsas possible. Explain the processes with comments. Cannot usefactor,primes, or isprime funtions.
Solution
function [primefactors] = primefactor(N)
%factor initialised to empty
factors = [];
%check if the number of divisible by 2, if yes keep on dividing inloop until its not
while (mod(N,2) == 0)
%store the factor as 2
factors = [factors 2];
N = N/2;
end
%start with 3 till square root of N
for i = 3:sqrt(N)
%check if the number of divisible by i, if yes store thefactor
while mod(N,i) ==
OR
OR