good level
not good, doesn't work for prime numbers
My idea was like Solution 1669655, that one is much better
The last test is not appropriate. 13916767508299776 exceeds flintmax, eg. 9.007199254740992e+15. It causes precision problem when it is passed to euler003.
I am failing to pass the last test of this code ,I am using max and factor ,any hint to pass last , 7th number test?
why it is not accepting the answer ;we cant make such small solutions we are not like professional coder
still something fishy with the 3rd problem, example:
x = uint64(321676750829977632);
num2str(x) -> 321676750829977600
rem(x,10) -> 0
euler003(x) -> 83653987
...?
ok now, it seems this was only an issue with my matlab version (7.7) but was not present in the version running the solvers (which seems to have uint64 arithmetic supported!, man, I need an upgrade...)
You should pass the x values as a string. A double precision number cannot resolve all the digits that one needs to solve the test suite problems:
>> x = 321676750829977632;
>> x == x+1
ans =
1
I agree that there is an issue with the last test suite problem. passing it as a uint64 would work too.
Yep I got "Error: Out of memory. Type HELP MEMORY for your options." :-)
function y = euler003(x)
i=1;
while true
while ~isprime(i)
i=i+1;
end
%找到下一个的质数
if(i^2>=x)
y=x;
return;
end
%如果质数的平方大于当前数，说明x已经不能再分解为质数的乘积
while mod(x,i)==0
x=x/i;
end
%累除
i=i+1;
end
end
Calculate the Levenshtein distance between two strings
548 Solvers
366 Solvers
Circular Primes (based on Project Euler, problem 35)
151 Solvers
Determine the number of odd integers in a vector
466 Solvers
Remove element(s) from cell array
512 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!