Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Primality tests: Add trivial code for seven-base#1562

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Artoria2e5 wants to merge1 commit intocp-algorithms:main
base:main
Choose a base branch
Loading
fromArtoria2e5:primez

Conversation

@Artoria2e5
Copy link

@Artoria2e5Artoria2e5 commentedNov 9, 2025
edited
Loading

The seven base version uses five fewer bases than the twelve-base version. That's 5 fewer binpower calls in the positive case, a 41.7% reduction. Based on that I think including the (very trivial) code for it is worthwhile.

Well, since we're already there, perhaps adding trial division with, say, the first 25 primes would greatly speed up the average case... nope, not going down that path.

Actually we should perhaps do go down that path. That's what every practical implementation does.


Most obvious place to add TD without adding another list of primes is after the(n == a) test. Just return false on(n % a == 0)!

But then you check godbolt gcc 15.2-O3 and --- what? it's usingdiv? What happened to division by constants being turned to some kind of mul? Turns out it only does that if you put the(n % a == 0) test in a separate loop from thecheck_composite test. And it never happens at-O2 possibly due to lack of loop unrolling. The more you know.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@Artoria2e5

[8]ページ先頭

©2009-2025 Movatter.jp