Jump to content

Cuban primes: Difference between revisions

m
Line 856:
cubans :: [Int]
cubans = [1..] >>= \x -> [(succ x ^ 3) - (x ^ 3)] >>= \r -> guard (isPrime r) >> [r]
 
thousands :: Int -> String
thousands = reverse . intercalate "," . chunksOf 3 . reverse . show
 
main :: IO ()
Line 865 ⟶ 862:
printf "\nThe 100,000th cuban prime is: %10s\n" $ thousands $ cubans !! 99999
where
rows = chunksOf 10 . take 200</lang>
thousands = reverse . intercalate "," . chunksOf 3 . reverse . show</lang>
{{out}}
<pre>
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.