fork(1) download
  1. import Data.Array.Unboxed
  2. import Control.Applicative ((<*>)) -- cf JBwoVL
  3. import Data.List (tails, inits) -- stackoverflow.com/a/42150321/849891
  4.  
  5. ps = 2 : [n | (r:q:_, px) <- (zip . tails . (2:) . map (^2) <*> inits) ps,
  6. (n,True) <- assocs (
  7. accumArray (\_ _ -> False) True (r+1,q-1)
  8. [(m,()) | p <- px, let s=(r+p)`div`p*p, m <- [s,s+p..q-1]]
  9. :: UArray Int Bool )]
  10.  
  11. main = do (print $ ps !! 10000000)
Success #stdin #stdout 9.84s 8388607KB
stdin
Standard input is empty
stdout
179424691