14 May 2011

Euler Project3 欧拉工程3



求600851475143的最大质因数
%% 600851475143's biggest prime factor
% Elapsed time is 55.277722 seconds.
% ans =
% 6857
function result = euler3()
tic;
result = 0;
n = 600851475143;
for i=fix(sqrt(n)):-1:3
if isprime(i)==1 && mod(n,i)==0
result = i;
break;
end
end
toc;
end

No comments :

Post a Comment