Hello,(adsbygoogle = window.adsbygoogle || []).push({});

I'm looking for some good and fast algorithm to find all prime numbers less than a given number. I've got a simple program which finds all primes less than any number, but once n gets above 500,000 it takes much too long. (More than 5 minutes. Just up to 100000 it takes about 7 seconds.)

My method is simply sieve of Eratosthenes, divide each number by every consecutive and so on. What'd be your method?

Thanks,

**Physics Forums - The Fusion of Science and Community**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Fast algorithm for finding number of p less than n

Loading...

Similar Threads for Fast algorithm finding | Date |
---|---|

Monte carlo algorithms in C++ | Jan 24, 2018 |

Best laptop (fast) under 300$-400$ | Sep 5, 2017 |

How fast can hackers crack 128 bit file encryption? | Jul 7, 2016 |

Is Adobe trying to pull a fast one? | May 19, 2015 |

Fast and cheap website hosts? | Mar 10, 2015 |

**Physics Forums - The Fusion of Science and Community**