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

Faster imsersenne #94

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

oscardssmith
Copy link
Member

Use trial division and pohlard's P-1 algorithm to speed up ismersenne when false. Based roughly on https://www.mersenne.org/various/math.php. The basic idea is that since almost no mersenne numbers are prime, it's worth doing some quick tests before going to LL.
For example, on ismersenne(big(2)^132049-1) this adds about 2.5 seconds of extra checks (compared to 80 seconds original runtime). However, these checks make the algorithm run in only the 2.5 seconds for the vast majority of outputs.

@oscardssmith
Copy link
Member Author

oscardssmith commented Feb 28, 2021

I've also realized that using mod_mersenne in ll_primecheck gives a 3.5x speedup for the function in the true case.

@oscardssmith
Copy link
Member Author

Any ideas why the 32 bit tests are timing out?

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

Successfully merging this pull request may close these issues.

1 participant