Smarandache prime-digital sequence: Difference between revisions

Content added Content deleted
Line 667: Line 667:
smarandache = [2,3,5,7] <> s [2,3,5,7] >>= \x -> guard (isPrime x) >> [x]
smarandache = [2,3,5,7] <> s [2,3,5,7] >>= \x -> guard (isPrime x) >> [x]
where
where
f g = g >>= \x -> [x*10+2, x*10+3, x*10+5, x*10+7]
s xs = r <> s r
s xs = r <> s r where r = f xs
where r = xs >>= \x -> [x*10+2, x*10+3, x*10+5, x*10+7]


nextSPDSTerms :: [Int] -> [(String, String)]
nextSPDSTerms :: [Int] -> [(String, String)]
Line 687: Line 687:
mapM_ (uncurry (printf "The %8sth SPDS: %15s\n")) $
mapM_ (uncurry (printf "The %8sth SPDS: %15s\n")) $
nextSPDSTerms [100, 1_000, 10_000, 100_000]
nextSPDSTerms [100, 1_000, 10_000, 100_000]
where f = show . take 25</lang>
where
f = show . take 25</lang>
{{out}}
{{out}}
<pre>
<pre>