Pierpont primes: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 941: | Line 941: | ||
</pre> |
</pre> |
||
=={{header|Haskell}}== |
=={{header|Haskell}}== |
||
Uses arithmoi Library: https://hackage.haskell.org/package/arithmoi-0.11.0.0 |
Uses arithmoi Library: https://hackage.haskell.org/package/arithmoi-0.11.0.0 for prime generation and prime testing. |
||
<lang haskell>import Control.Monad (guard) |
<lang haskell>import Control.Monad (guard) |
||
import Data.List (intercalate) |
import Data.List (intercalate) |
||
Line 968: | Line 968: | ||
pierpoints k = do |
pierpoints k = do |
||
n <- nSmooth 3 |
n <- nSmooth 3 |
||
let x = case k of First -> |
let x = case k of First -> succ n |
||
Second -> n |
Second -> pred n |
||
guard (isPrime x) |
guard (isPrime x) |
||
[x] |
[x] |
||
Line 1,006: | Line 1,006: | ||
./pierpoints 0.04s user 0.01s system 20% cpu 0.215 total |
./pierpoints 0.04s user 0.01s system 20% cpu 0.215 total |
||
</pre> |
</pre> |
||
=={{header|Java}}== |
=={{header|Java}}== |
||
<lang java> |
<lang java> |