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

lab 6: 6a, 6b, 7 #10

Open
BertLisser opened this issue Oct 17, 2017 · 0 comments
Open

lab 6: 6a, 6b, 7 #10

BertLisser opened this issue Oct 17, 2017 · 0 comments

Comments

@BertLisser
Copy link

BertLisser commented Oct 17, 2017

6a (=10)

Then you can variate
6b:

getKMersenne :: Integer -> Integer -> [Integer] -> IO [Integer]

easier

getKMersenne :: Int -> Int -> [Integer] -> IO [Integer]
getKMersenne k n z = if genericLength z == n then return z else do
    i <- primeMR 1 (2^p - 1)
    if i then getKMersenne (k+1) n (z++[p]) else getKMersenne (k+1) n z
where p = primes !! (fromIntegral k)

Interesting to variate the first argument in primeMR.

I don't understand.

-- while using k=6 (exercise 6 shows that from k=6 and higher the check is not fooled by carmichael numbers),
-- it takes about 30 seconds. Both ks return the correct first 20 Mersenne primes.
-- The first 20 Mersenne primes can be discovered relatively quickly.

Not with primeMR 1 (2^p - 1)

6b (=6

7(=10)
7 (

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

1 participant