Write a program in the Haskell Language to finds ALL twin pr
Write a program in the Haskell Language to finds ALL twin primes and display them in tuples in a list. Such as [(3,5),(5,7),(11, 13),...]
Solution
Ans
x:: Integer -> Bool
y:: Integer -> Bool
areTwoApart (x,y) = y - x == 2
Prelude> take 10 $ filter areTwoApart (zip allprimes (tail allprimes))
It will give you first ten prime twins
Or
main=putStrLn.(!!)
[show n++\", \"++show(n+2)|n<-[2..],all((>0).rem n)[2..n-1],all((>0).rem(n+2))[2..n]].(+)(-1)=<<readLn
![Write a program in the Haskell Language to finds ALL twin primes and display them in tuples in a list. Such as [(3,5),(5,7),(11, 13),...]SolutionAns x:: Integer Write a program in the Haskell Language to finds ALL twin primes and display them in tuples in a list. Such as [(3,5),(5,7),(11, 13),...]SolutionAns x:: Integer](/WebImages/47/write-a-program-in-the-haskell-language-to-finds-all-twin-pr-1147396-1761617037-0.webp)