Number of primes below a given number

Yup - that would add a dependency to primecount, but I think that’s accessible. If any newcomers want to PR that, feel free to DM and I’ll mentor through the process.

Concretely, we wouldn’t want to spawn an external process with run(...) every time we want to count primes - we want to call to the C ABI with @ccall so that this is just a direct function call:

julia> myprimecount(x) = @ccall libprimecount.primecount_pi(x::Clonglong)::Clonglong
myprimecount (generic function with 1 method)

julia> @time myprimecount(1e8)
  0.001004 seconds
5761455

julia> @time myprimecount(1e14)
  0.149201 seconds
3204941750802

This would include wrapping up the different options in the exposed command line options with appropriate dispatches.

This means that your mission, should you choose to accept it, would be a Pull Request to Primes.jl that

  1. adds primecount_jll as a dependency (easy: fork the repo, dev the repo, activate the environment, and add primecount as a normal package).
  2. add functions + dispatch for all the appropriate @ccalls exposed in the commandline options in primecount’s README.
  3. add tests to make sure that everything you added works.

Once that’s done, a good open source citizen would also PR the primecount github repo’s README to add Primes.jl as an Julia wrapper in their documentation (and/ or buy kimwalish et al a coffee).

14 Likes