%My challenge is to find the number of divisors for a number without using "divisors" inbuild function
%this program will work but it's taking too much time for big numbers
%I read about vectorization to reduce the time but found stucked
%help!!!
function y=divisors1(N)sum=0;for i=1:floor(N/2)if lcm(N,i)==Nsum=sum+1;endendy=1+sum;
MATLAB: Speeding up the for loop
for looploopsspeeding up the program
Best Answer