# Number of primes below a given number

**URL:** <https://discourse.julialang.org/t/number-of-primes-below-a-given-number/58709>\
**Category:** Numerics\
**Tags:** question\
**Created:** [April 6, 2021, 6:36pm UTC](https://discourse.julialang.org/t/number-of-primes-below-a-given-number/58709 "2021-04-06T18:36:30Z")\
**Posts on this page:** 12\
**Page:** 3

<div class="post-metadata">

**Author:** ![reinermartin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/reinermartin/32/25574_2.png) [@reinermartin](https://discourse.julialang.org/u/reinermartin)\
**Post date:** [May 28, 2021, 4:44pm UTC](https://discourse.julialang.org/t/number-of-primes-below-a-given-number/58709/41 "2021-05-28T16:44:00Z")

</div>

Just for interest, do you need this for [Project Euler](https://projecteuler.net/) problems? There, you often need the exact prime count and related quantities for limits such as 10^{12} or 10^{14} etc. There is extensive discussion on these issues in the forums (alas, you need to have solved the problem before you get access to the associated forum). BTW, I use Julia extensively for Project Euler (it is the perfect language for that!), and I have posted prime counting related code in the forums.

---

<div class="post-metadata">

**Author:** ![HexSpin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hexspin/32/19319_2.png) [@HexSpin](https://discourse.julialang.org/u/HexSpin)\
**Post date:** [May 28, 2021, 5:11pm UTC](https://discourse.julialang.org/t/number-of-primes-below-a-given-number/58709/42 "2021-05-28T17:11:31Z")

</div>

Thank you for asking! No, it’s not for Project Euler, which is new to me (but very interesting!). I’m computationally exploring a mathematical structure I call the prime hexagon. If you are still interested, here’s a 4 year old video I made about it … it doesn’t reflect well what I’m up to now, but may give you a rough idea.

[![](https://global.discourse-cdn.com/julialang/original/3X/7/9/79ed8ec9923e1beaa3f4f542c5a72dfe46f3a516.jpeg "Prime Hexagon - Introduction") ](https://www.youtube.com/watch?v=fQL4KRH3wUQ)

---

<div class="post-metadata">

**Author:** ![HexSpin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hexspin/32/19319_2.png) [@HexSpin](https://discourse.julialang.org/u/HexSpin)\
**Post date:** [June 8, 2021, 5:46pm UTC](https://discourse.julialang.org/t/number-of-primes-below-a-given-number/58709/43 "2021-06-08T17:46:44Z")

</div>

I’m sorry. I replied below, but neglected to tag you.

---

<div class="post-metadata">

**Author:** ![HexSpin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hexspin/32/19319_2.png) [@HexSpin](https://discourse.julialang.org/u/HexSpin)\
**Post date:** [June 30, 2023, 6:02pm UTC](https://discourse.julialang.org/t/number-of-primes-below-a-given-number/58709/44 "2023-06-30T18:02:42Z")

</div>

Hello, two years later! I’m considering switching to PrimeSieve.jl (replacing Primes.jl) because I suspect it is far faster for generating very large prime arrays. Have you, by chance, benchmarked them against each other?  
Thanks!

---

<div class="post-metadata">

**Author:** ![jlapeyre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlapeyre/32/4514_2.png) [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)\
**Post date:** [June 30, 2023, 7:59pm UTC](https://discourse.julialang.org/t/number-of-primes-below-a-given-number/58709/45 "2023-06-30T19:59:41Z")

</div>

PrimeSieve.jl has not been maintained. It’s broken. If it’s not archived, I should do it.

---

<div class="post-metadata">

**Author:** ![HexSpin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hexspin/32/19319_2.png) [@HexSpin](https://discourse.julialang.org/u/HexSpin)\
**Post date:** [June 30, 2023, 8:18pm UTC](https://discourse.julialang.org/t/number-of-primes-below-a-given-number/58709/46 "2023-06-30T20:18:20Z")

</div>

Okay - thanks for getting back.

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [June 30, 2023, 9:09pm UTC](https://discourse.julialang.org/t/number-of-primes-below-a-given-number/58709/47 "2023-06-30T21:09:24Z")

</div>

I very much wouldn’t mind prs to make primes.jl faster 🙂 there’s some relatively low hanging fruit

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [July 1, 2023, 9:28am UTC](https://discourse.julialang.org/t/number-of-primes-below-a-given-number/58709/48 "2023-07-01T09:28:28Z")

</div>

We’ve all known that since reading [A humble request/challenge](https://discourse.julialang.org/t/a-humble-request-challenge/5286) :troll:

---

<div class="post-metadata">

**Author:** ![HexSpin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hexspin/32/19319_2.png) [@HexSpin](https://discourse.julialang.org/u/HexSpin)\
**Post date:** [July 2, 2023, 12:52pm UTC](https://discourse.julialang.org/t/number-of-primes-below-a-given-number/58709/49 "2023-07-02T12:52:09Z")

</div>

I’d second that!

---

<div class="post-metadata">

**Author:** ![HexSpin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hexspin/32/19319_2.png) [@HexSpin](https://discourse.julialang.org/u/HexSpin)\
**Post date:** [July 2, 2023, 12:52pm UTC](https://discourse.julialang.org/t/number-of-primes-below-a-given-number/58709/50 "2023-07-02T12:52:25Z")

</div>

I’ll have to read up on this!

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [July 2, 2023, 4:56pm UTC](https://discourse.julialang.org/t/number-of-primes-below-a-given-number/58709/51 "2023-07-02T16:56:07Z")

</div>

I think you will find [this thread](https://discourse.julialang.org/t/can-julia-do-this-algorithm-faster/74516) interesting then.

---

<div class="post-metadata">

**Author:** ![HexSpin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hexspin/32/19319_2.png) [@HexSpin](https://discourse.julialang.org/u/HexSpin)\
**Post date:** [July 3, 2023, 11:39am UTC](https://discourse.julialang.org/t/number-of-primes-below-a-given-number/58709/52 "2023-07-03T11:39:08Z")

</div>

Interesting until it turned into a proof of twin prime conjecture brawl. 🙂

[Previous page](https://discourse.julialang.org/t/number-of-primes-below-a-given-number/58709.md?page=2)
