import Data.List
-- funcion que toma dos listas ordenadas y sin repetidos, y retorna una lista
-- con los elementos de la primera que no estan en la segunda
minus
(x:xs
) (y:ys
) = case (compare x y
) of LT -> x : minus xs (y:ys)
EQ -> minus xs ys
GT -> minus (x:xs) ys
-- [2..] representa la lista infinita: [2,3,4,5,...]
-- erathos es la implenetación de la criba de erathostenes
primes = eratos [2..]
where
eratos [] = []
eratos (p:xs) = p : eratos (minus xs [p, p+p..])
-- primes representa la lista infinita de todos los primos, pero como
-- "take 20 primes" dice que solo se van a utilizar los 20 primeros, haskell
-- solo calcula los primeros 20
aW1wb3J0IERhdGEuTGlzdAoKLS0gZnVuY2lvbiBxdWUgdG9tYSBkb3MgbGlzdGFzIG9yZGVuYWRhcyB5IHNpbiByZXBldGlkb3MsIHkgcmV0b3JuYSB1bmEgbGlzdGEKLS0gY29uIGxvcyBlbGVtZW50b3MgZGUgbGEgcHJpbWVyYSBxdWUgbm8gZXN0YW4gZW4gbGEgc2VndW5kYQptaW51cyAoeDp4cykgKHk6eXMpID0gY2FzZSAoY29tcGFyZSB4IHkpIG9mIAogICBMVCAtPiB4IDogbWludXMgIHhzICAoeTp5cykKICAgRVEgLT4gICAgIG1pbnVzICB4cyAgICAgeXMgCiAgIEdUIC0+ICAgICBtaW51cyAoeDp4cykgIHlzCgotLSBbMi4uXSByZXByZXNlbnRhIGxhIGxpc3RhIGluZmluaXRhOiBbMiwzLDQsNSwuLi5dCi0tIGVyYXRob3MgZXMgbGEgaW1wbGVuZXRhY2nDs24gZGUgbGEgY3JpYmEgZGUgZXJhdGhvc3RlbmVzCnByaW1lcyA9IGVyYXRvcyBbMi4uXQogIHdoZXJlCiAgICBlcmF0b3MgW10gPSBbXQogICAgZXJhdG9zIChwOnhzKSA9IHAgOiBlcmF0b3MgKG1pbnVzIHhzIFtwLCBwK3AuLl0pCgotLSBwcmltZXMgcmVwcmVzZW50YSBsYSBsaXN0YSBpbmZpbml0YSBkZSB0b2RvcyBsb3MgcHJpbW9zLCBwZXJvIGNvbW8KLS0gInRha2UgMjAgcHJpbWVzIiBkaWNlIHF1ZSBzb2xvIHNlIHZhbiBhIHV0aWxpemFyIGxvcyAyMCBwcmltZXJvcywgaGFza2VsbAotLSBzb2xvIGNhbGN1bGEgbG9zIHByaW1lcm9zIDIwCm1haW4gPSBwcmludCAkICh0YWtlIDIwIHByaW1lcyk=
[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71]