I’m surprised no one is mentioning Haskell. This is unoptimized, and I haven’t used Haskell in a while so bear with me. This might not compile. Also, Data.Numbers.Primes is from https://hackage.haskell.org/package/primes.
import Data.Numbers.Primes (isPrime)
primes = filter isPrime [1..]
halfOfClosePrimes n = ((primes !! n - 1) + (primes !! n + 1)) `div` 2
isStrong n = (primes !! n) > halfOfClosePrimes n
isWeak n = (primes !! n) < halfOfClosePrimes n
strongs = map (primes !!) $ filter isStrong [1..]
weaks = map (primes !!) $ filter isWeak [1..]
main = do
putStr "Strongs: "
print $ take 10 strongs
putStr "Weaks: "
print $ take 10 weaks
I’m surprised no one is mentioning Haskell. This is unoptimized, and I haven’t used Haskell in a while so bear with me. This might not compile. Also, Data.Numbers.Primes is from
https://hackage.haskell.org/package/primes
.