This code takes an extremely long time to run (more than 10 minutes). Is there any way in which I can optimize it so that it finishes in less than one minute?
clear all;
for i = 1:1000000
harmonicsum = 0;
lhs = 0;
for j = 1:i
% compute harmonic sum
harmonicsum = harmonicsum + 1/j;
% find sum of factors
if (mod(i,j)==0)
lhs = lhs + j;
end
end
%define right hand side (rhs) of Riemann Hypothesis
rhs = harmonicsum + log(harmonicsum) * exp(harmonicsum);
if lhs > rhs
disp('Hypothesis violated')
end
end