feat(maths): add repunit theorem helpers (v3)#14548
Open
nickzerjeski wants to merge 1 commit intoTheAlgorithms:masterfrom
Open
feat(maths): add repunit theorem helpers (v3)#14548nickzerjeski wants to merge 1 commit intoTheAlgorithms:masterfrom
nickzerjeski wants to merge 1 commit intoTheAlgorithms:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a small number-theory helper module for working with repunits (numbers of the form 111…1) and checking/deriving repunit divisibility properties, addressing the requested “repunit theorem” functionality in #13999.
Changes:
- Add
has_repunit_multiple(divisor)to determine when a repunit multiple can exist (i.e.,gcd(divisor, 10) == 1). - Add
least_repunit_length(divisor)to compute the smallest repunit length divisible bydivisorusing modular iteration (no large integer construction).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ``R_k = 11...1``. | ||
|
|
||
| For every positive integer ``n`` with ``gcd(n, 10) = 1``, | ||
| there exists a repunit ``R_k`` divisible by ``n``. |
There was a problem hiding this comment.
The module docstring introduces the repunit theorem but doesn’t include any reference URL. New algorithm modules in this repo typically include at least one Wikipedia (or similar) link; please add a reference (e.g., Repunit, multiplicative order, or the repunit divisibility theorem) to satisfy the project’s documentation expectations.
Suggested change
| there exists a repunit ``R_k`` divisible by ``n``. | |
| there exists a repunit ``R_k`` divisible by ``n``. | |
| References: | |
| - https://en.wikipedia.org/wiki/Repunit | |
| - https://en.wikipedia.org/wiki/Multiplicative_order |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your change:
Fixes #13999
Checklist: