default.txt 668 B

123456789101112131415161718192021222324252627282930
  1. module fsieve
  2. import StdClass; // RWS
  3. import StdInt, StdReal
  4. NrOfPrimes :== 3000
  5. primes :: [Int]
  6. primes = pr where pr = [5 : sieve 7 4 pr]
  7. sieve :: Int !Int [Int] -> [Int]
  8. sieve g i prs
  9. | isPrime prs g (toInt (sqrt (toReal g))) = [g : sieve` g i prs]
  10. | otherwise = sieve (g + i) (6 - i) prs
  11. sieve` :: Int Int [Int] -> [Int]
  12. sieve` g i prs = sieve (g + i) (6 - i) prs
  13. isPrime :: [Int] !Int Int -> Bool
  14. isPrime [f:r] pr bd
  15. | f>bd = True
  16. | pr rem f==0 = False
  17. | otherwise = isPrime r pr bd
  18. select :: [x] Int -> x
  19. select [f:r] 1 = f
  20. select [f:r] n = select r (n - 1)
  21. Start :: Int
  22. Start = select [2, 3 : primes] NrOfPrimes