This repository contains algorithms written in MATLAB/Octave. Developing algorithms in the MATLAB environment empowers you to explore and refine ideas, and enables you test and verify your algorithm.
Current implementation doesn't work due to idivide function - arguments shoud have integer types (not double).
After replacing it by number /= divisor implementation works impossible long.
To speed up the program - we should decrease number after divisions by divisors and therefore upper bound sqrt(number) in loop for divisors will decrease quite fast (for loop should be replaced with while to enable upper bound decrease).
And function isPrime is redundant here, because all added divisors will be prime. So, final implementation turned out to be very similar to link
Current implementation doesn't work due to
idivide
function - arguments shoud have integer types (notdouble
). After replacing it bynumber /= divisor
implementation works impossible long.To speed up the program - we should decrease
number
after divisions bydivisor
s and therefore upper boundsqrt(number)
in loop fordivisor
s will decrease quite fast (for
loop should be replaced withwhile
to enable upper bound decrease).And function
isPrime
is redundant here, because all addeddivisor
s will be prime. So, final implementation turned out to be very similar to link