Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Week 6: if you have read this and you have no questions, please close this issue. #3

Closed
BertLisser opened this issue Oct 16, 2013 · 0 comments

Comments

@BertLisser
Copy link

Clear concise report (++) with beauties of Haskell functions like

-- Exercise 3: Composites sieve.
composites :: [Integer]
composites = map fst (filter (not . snd) (sieve' [2..]))

-- characterize numbers by prime property
sieve' :: [Integer] -> [(Integer,Bool)]
sieve' ns = let ps = (sieve [2..])
            in map (\ n -> (n, (inlist n ps))) ns
            where inlist n (p:ps) | p < n = inlist n ps
                                  | p == n = True
                                  | otherwise = False

The test results are very readable. One remark:
There are more carmichael numbers than {(6k+1)(12k+1)(18k+1)}
(see solutions Lab6)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants