2017-05-29 03:23:39 +00:00
|
|
|
{-# LANGUAGE BangPatterns #-}
|
2017-05-18 06:40:44 +00:00
|
|
|
import Data.List
|
|
|
|
|
2017-05-29 03:23:39 +00:00
|
|
|
upper = 8000
|
2017-05-18 06:40:44 +00:00
|
|
|
|
|
|
|
isPrime :: Int -> Bool
|
|
|
|
isPrime x = null [k | k <- [2..x-1], k * k <= x, x `mod` k == 0]
|
|
|
|
|
2017-05-29 03:23:39 +00:00
|
|
|
!primes = [x | x <- [2..upper], isPrime x]
|
2017-05-18 06:40:44 +00:00
|
|
|
|
|
|
|
isPrimeNew :: Int -> Bool
|
|
|
|
isPrimeNew x
|
|
|
|
| x <= upper = elem x primes
|
|
|
|
| otherwise = isPrime x
|
|
|
|
|
|
|
|
isPrimePair :: Int -> Int -> Bool
|
|
|
|
isPrimePair a b = isPrime(read(show a ++ show b)) && isPrime(read(show b ++ show a))
|
|
|
|
|
|
|
|
primePairs = [(a, b) | a <- primes, b <- primes, a < b, isPrimePair a b]
|
|
|
|
|
2017-05-29 03:23:39 +00:00
|
|
|
primeSets = [(a, b, c, d, e) | a <- primes,
|
|
|
|
b <- primes,
|
|
|
|
a < b,
|
|
|
|
isPrimePair b a,
|
|
|
|
|
|
|
|
c <- primes,
|
|
|
|
b < c,
|
|
|
|
isPrimePair c a,
|
|
|
|
isPrimePair c b,
|
|
|
|
|
|
|
|
d <- primes,
|
|
|
|
c < d,
|
|
|
|
isPrimePair d a,
|
|
|
|
isPrimePair d b,
|
|
|
|
isPrimePair d c,
|
|
|
|
|
|
|
|
e <- primes,
|
|
|
|
d < e,
|
|
|
|
isPrimePair e a,
|
|
|
|
isPrimePair e b,
|
|
|
|
isPrimePair e c,
|
|
|
|
isPrimePair e d]
|
|
|
|
|
|
|
|
|
|
|
|
main = print $ head primeSets
|