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

Fix broken miller-rabin primality test #3

Merged
merged 2 commits into from
Dec 6, 2021
Merged

Fix broken miller-rabin primality test #3

merged 2 commits into from
Dec 6, 2021

Conversation

evrhines
Copy link
Contributor

@evrhines evrhines commented Dec 6, 2021

Only return early if we did not break due to the (n-1) case. Otherwise, we need to 'goto' the outer loop and repeat. See the pseudocode: https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test. Note the continue WitnessLoop which was previously just a break in this code.

Added some tests to verify the functionality.

This fixes the issues mentioned in issue #1 .

Some of the existing tests seem to fail/run forever(Verification::is_very_smooth_number, factorization) on master; however, I verified that the new tests pass.

Only return early if we did not break due to the (n-1) case. Otherwise,
we need to 'goto' the outer loop and repeat
@AtropineTears
Copy link
Owner

Looks great and works. I will merge it in now!

@AtropineTears AtropineTears merged commit a5cc125 into AtropineTears:master Dec 6, 2021
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.

2 participants