dexman545

Number Fun

Feb 21st, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --ghc 7.10
  2.  
  3. main = print $ test
  4.  
  5. fibinacci = 1:1:[a + b | (a,b) <- zip fibinacci $ tail fibinacci]
  6.  
  7. factorial 0 = 1
  8. factorial n = n * factorial (n-1)
  9.  
  10. test = primes !! 1000
  11.  
  12. --isPrime n = all (/=0) [n `mod` p | p <- takeWhile (<n) primes]
  13.  
  14. --primes = 2:[x | x <- [3..], isPrime x]
  15.  
  16. primes = filterPrime [2..]
  17.   where filterPrime (p:xs) =
  18.           p : filterPrime [x | x <- xs, x `mod` p /= 0]
Add Comment
Please, Sign In to add comment