mirror of
https://github.com/TheAlgorithms/C.git
synced 2026-02-14 05:44:36 +00:00
[FEATURE]: The Repunit theorem #208
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ridge-kimani on GitHub (Dec 11, 2025).
Detailed description
Add Repunit theorem
Issue details
Numbers formed by repeating digits or repeating blocks—such as 111111, 424424, or structures like 10ⁿ + 1 (e.g., 100000001)—follow predictable patterns in number theory. These patterns are not random; they arise from the multiplicative order of 10 modulo a prime.
Context
Right now, we treat these numbers as arbitrary integers, which leads to three core problems:
Repeated-digit numbers have a very specific factorization rule (e.g., 100000001 being divisible by 17). Without modeling the underlying theorem, our current logic either:
Because these numbers are treated on a case-by-case basis, any function that needs to handle:
ends up re-implementing partial logic, often incorrectly or inefficiently. Bringing this into a unified mathematical rule improves maintainability and correctness.
Repeated-digit integers can be extremely large (sometimes more than a million digits long).
Using the multiplicative-order approach lets us compute divisibility using O(log n) modular arithmetic and without building the actual number at all.
With this algorithm in place, once the multiplicative order is part of the system, it unlocks:
I believe this will be a good one to tackle, given that it's an unresolved problem in number theory.
Examples
These examples show actual numbers, their patterns, and the mathematical reason they’re divisible by certain primes.
1. Classic example: 100000001 is divisible by 17
Why?
100000001 = 10⁸ + 1The multiplicative order of 10 modulo 17 is 8, meaning:
So:
Actually:
Therefore:
2. Repeated block example: 424424
Block:
424Repeated twice → total structure:
424424Divisible by:
Why?
424424 = 424 × 1001, and:The fact that 1001 factors into 7, 11, and 13 comes from the multiplicative order of 10 modulo those primes.
3. Repunit example: 111111
111111is6repeated digits of1.It equals:
Divisible by:
Why these primes?
Because the multiplicative order of 10 modulo each of those primes divides 6.
For example:
So all of them divide
111111.4. Repeated digit example: 999999999 (9 repeated 9 times)
This is:
And
111,111,111has divisors:Again, it is determined by which primes have multiplicative order dividing 9.
5. Three-block repeated pattern: XYZXYZXYZ
Example:
123123123This is:
Prime factors of 1,001,001:
All these primes divide the repeated-block number because their orders divide 3×3.
6. Palindromic power example: 10⁶ − 1 = 999999
Divisible by:
The factor
37is the famous one here because:which again is tied to the order of 10 modulo 37 (which is 3).
7. Full reptend prime example
A prime is "full reptend" in base 10 if the order of 10 mod p is p−1.
Example:
This is why:
and why repunit length = 6.
Possible workarounds
No response
Additional information
No response
Additional Information
No response
Possible implementation
No response
Additional information
No response
@github-actions[bot] commented on GitHub (Jan 11, 2026):
This issue has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@github-actions[bot] commented on GitHub (Jan 19, 2026):
Please ping one of the maintainers once you add more information and updates here. If this is not the case and you need some help, feel free to ask for help in our Gitter channel or our Discord server. Thank you for your contributions!