We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Does anyone have any hints how to make this Python code faster? Is it possible to get it fast enough without converting to C? I thought my algorithm is already fairly optimal but apparently not.
The idea is basically to get all the primes, then for each prime a, use bisection to find the prime b where a * b > N. So I would say the complexity is T N log N for that part and N loglog N for finding primes.
Project Euler #187: Semiprimes
You are viewing a single comment's thread. Return to all comments →
Does anyone have any hints how to make this Python code faster? Is it possible to get it fast enough without converting to C? I thought my algorithm is already fairly optimal but apparently not.
The idea is basically to get all the primes, then for each prime
a
, use bisection to find the primeb
wherea * b > N
. So I would say the complexity isT N log N
for that part andN loglog N
for finding primes.