2

Is the NetBSD primes utility (or equivalent) available on MacOS in any package, other than via manual download-and-compile (e.g. curl)? I searched quite a lot and couldn't find any package (other than the NetBSD CVS source).

(NetBSD primes is not a prime-sieve to find large/as-yet-unknown primes, just a simple command-line utility which tells you which integers are prime (or composite) in a given (64b) range).

(Unlike Gnu factor which is available via package coreutils "Finding Prime Numbers - “factor” command not found on MacOS", "Is there a practical use for the GNU factor command?")

Note: this question does not belong on AskDifferent since there is no brew/macports package.

smci
  • 173
  • 9
  • @slm: I already cited those answers above in my question(!). The lack of acceptable answer was the motivator for this question. So, is `primes` NetBSD only, or is it (or an equivalent) in other Unixes? – smci Jul 14 '18 at 01:23
  • 1
    Sorry, I missed those #1, #2 links. It's NetBSD only, I installed it long ago on a couple of Linux boxes and I had to build it from source in those instances as well. – slm Jul 14 '18 at 01:24

1 Answers1

1

I've never been able to find it in any pre-built package but in this SO Q&A titled: Finding Prime Numbers - “factor” command not found on MacOS, someone posted a Makefile which you can use to download and build factor and primes yourself.

primesieve

As an alternative, there's this package called primesieve which is a different implementation than the NetBSD primes, but is available in brew:

$ brew info primesieve
primesieve: stable 7.0 (bottled)
Fast C/C++ prime number generator
https://primesieve.org/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/primesieve.rb
==> Dependencies
Build: cmake ✔
slm
  • 363,520
  • 117
  • 767
  • 871
  • Thanks for `primesieve`. I had already cited the answer above when I asked my question and as you saw I don't find the manual-download-and-compile approach acceptable. I was surprised other Unix users never added `primes`. – smci Jul 14 '18 at 01:30
  • @smci - I believe it's not installed because there are better alternatives at this point. The original NetBSD primes was written in 1980's-1990's. There's a list of alternatives on the `primesieves` webpage - https://primesieve.org/links.html#implementations. – slm Jul 14 '18 at 01:31
  • Indeed, but not on the Unix command-line. I was just looking for something fast-and-cheerful. `primesieve` looks fine. Specifically, `fmt -120 <(primesieve 1e6 --print)` or `paste -s <(...)` – smci Jul 14 '18 at 01:39
  • 1
    @smci - I seem to recall another primes app that I installed long ago on Fedora, let me look a bit more b/c you've now peeked by curiosity 8-) – slm Jul 14 '18 at 01:41
  • 1
    @smci - found it - it was this one - https://www.mersenne.org/download/. I'm sure you already knew about this one. I used to use it to stress test HW – slm Jul 14 '18 at 01:46
  • No, GIMPS is only about the search for (large) primes, and then only Mersenne primes. I just wanted a simple prime-sieve which tells me what in an integer range is composite and what is prime (at least up to 64b), on the UNIX command-line. I already knew about GIMPS; it was not the droid I'm looking for. – smci Jul 14 '18 at 01:53
  • 1
    @smci - True. My memory of it is long gone then, I just remember finding that same NetBSD `primes` app and then finding it (or some alt) that was packaged as a RPM/SRPM and messing around w/ it on one of my systems. I know it was a sieve implementation b/c I had used it to look at how it was implemented when I found out about them. Oh well... – slm Jul 14 '18 at 02:00