Erdos-Straus Solution Counter
GPU kernel for counting solutions to the Erdos-Straus equation:
for each prime , where .
The Erdos-Straus conjecture (1948) asserts that for all primes . This kernel computes the exact count of ordered solutions for every prime in a batch.
Usage
# /// script
# dependencies = ["torch", "kernels"]
# ///
import torch
from kernels import get_kernel
erdos_straus = get_kernel("cahlen/erdos-straus-cuda")
# Count solutions for a batch of primes
primes = torch.tensor([2, 3, 5, 7, 11, 13, 97, 9973], dtype=torch.int64, device="cuda")
counts = erdos_straus.count(primes)
print(dict(zip(primes.tolist(), counts.tolist())))
# {2: 1, 3: 3, 5: 2, 7: 5, 11: 8, 13: 12, 97: 251, 9973: 62624}
API
erdos_straus.count(primes: Tensor) -> Tensor
| Parameter | Type | Description |
|---|---|---|
primes |
Tensor[int64] (1-D, CUDA) |
Batch of primes to count solutions for |
| Returns | Tensor[int32] (1-D, CUDA) |
Solution count for each prime |
Algorithm
For each prime , the kernel enumerates all valid triples:
- Iterate from to
- Compute the remainder fraction and iterate in the valid range
- Check if is a positive integer with
Each thread handles one prime. Throughput scales linearly with GPU cores.
Results
Verified on 8x NVIDIA B200 GPUs at bigcompute.science:
- 10^8: 5.76M primes, conjecture holds (all )
- 10^9: 50.8M primes, in progress
All data open at github.com/cahlen/idontknow.
Citation
@misc{humphreys2026erdosstraus,
author = {Humphreys, Cahlen},
title = {GPU-Accelerated Erdos-Straus Solution Counting},
year = {2026},
url = {https://bigcompute.science}
}
Human-AI collaborative research. Not peer-reviewed. All code and data open for verification.
- Downloads last month
- -
Inference Providers NEW
This model isn't deployed by any Inference Provider. π Ask for provider support