
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Comprehensive prime number utilities with multiple algorithms including the novel Hyperbolic Equation Method with intelligent caching
This repository contains both JavaScript and Python implementations for prime number computations using multiple mathematical approaches including the novel Hyperbolic Equation Method.
Note: While the JavaScript implementations are highly functional and optimized, Python methods are generally quicker due to their efficient handling of numerical computations and file I/O operations.
This repository includes multiple approaches to prime number computation:
All primes > 3 are of form 6k±1
Proof:
Therefore, only 2 out of every 6 positions need testing (33% of numbers).
For composite numbers in 6k±1 form:
For 6n+1:
For 6n-1:
This approach transforms the prime factorization problem into solving hyperbolic equations, providing a geometric perspective on primality testing.
For a number of form 6n+1, if composite, it factors as (6k+1)(6kk+1).
We can express this as a quadratic equation:
k² - sk + p = 0
where: s = k + kk, p = k·kk
From: n = 6k·kk + k + kk = 6p + s
We have: s = n - 6p
The discriminant: δ = s² - 4p = (n-6p)² - 4p = n² - 12np + 36p² - 4p
For integer solutions, δ must be a perfect square: δ = r²
This gives us: n² - 12np + 36p² - 4p - r² = 0
Solving for p using the quadratic formula and requiring integer solutions:
δ' = 16(3n+1)² - 144(n²-r²) = 16(9r² + 6n + 1)
For δ' to be a perfect square, we need:
Rearranging:
Similarly, for numbers of form 6n-1:
Rearranging:
These are hyperbola equations in the (r, m) plane:
For 6n+1: m² - 9r² = 6n+1
For 6n-1: 9r² - m² = 6n-1
To check if a number is composite:
For 6n+1:
for r = 0 to √n:
discriminant = 9r² + 6n + 1
m = √discriminant
if m² == discriminant: # Perfect square
check = m - 3r - 1
if check % 6 == 0 and check >= 6:
divisor = check + 1
return composite (divisor found)
return prime (no divisor found)
✅ Mathematical Elegance: Transforms factorization into geometry ✅ Educational Value: Shows connection between algebra and number theory ✅ Alternative Perspective: Different from trial division approach ✅ Potentially Novel: Specific formulation may be unique
🔍 Areas for investigation:
Now production-ready with major improvements!
The optimized implementation includes:
Available in both JavaScript and Python:
src/services/primeHyperbolic.optimized.mjsfm_prime/prime_hyperbolic_optimized.pyOriginal research version (for educational purposes) remains in /investigation folder.
# Install globally
npm install -g primefm
# Or install in your project
npm install primefm
# Or use directly without installing
npx primefm
Package URL: https://www.npmjs.com/package/primefm
pip install primefm
Using the installed package:
# JavaScript - after npm install -g primefm
primefm
# Or use directly
npx primefm
# Python - after pip install primefm (coming soon)
primefm
For local development:
# JavaScript
node findPrimes.mjs
# Python
python3 findPrimes.py
Both provide an interactive menu to choose from 6 different prime-finding methods.
// After: npm install primefm
import { isPrimeOptimized } from 'primefm/checker';
import { sieveWheel210 } from 'primefm/wheel210';
import { sieveHyperbolicOptimized } from 'primefm/hyperbolic';
// Check single prime
console.log(isPrimeOptimized('999983')); // true
// Find all primes up to 100,000 (Wheel-210)
const primes = sieveWheel210('100000');
console.log(`Found ${primes.length} primes`);
// Find all primes with caching (very fast for repeated use)
const cachedPrimes = sieveHyperbolicOptimized('100000');
console.log(`Found ${cachedPrimes.length} primes`);
import { isPrimeOptimized } from './src/services/primeChecker.optimized.mjs';
import { sieveWheel210 } from './src/services/wheel210.optimized.mjs';
import { sieveHyperbolicOptimized } from './src/services/primeHyperbolic.optimized.mjs';
# After: pip install primefm (once published)
# from primefm import is_prime_optimized, sieve_wheel210, sieve_hyperbolic_optimized
# For now, use local imports:
import sys
sys.path.insert(0, 'src/services-py')
from prime_optimized import is_prime_optimized
from wheel210 import sieve_wheel210
from prime_hyperbolic_optimized import sieve_hyperbolic_optimized
# Check single prime
print(is_prime_optimized(999983)) # True
# Find all primes up to 100,000 (Wheel-210)
primes = sieve_wheel210(100000)
print(f"Found {len(primes)} primes")
# Find all primes with caching (very fast for repeated use)
cached_primes = sieve_hyperbolic_optimized(100000)
print(f"Found {len(cached_primes)} primes")
Explore the hyperbolic approach visually:
python analyze-hyperbolic-visual.py # Generates plots
python analyze-hyperbolic-patterns.py # Text analysis
See the examples/ directory for complete working examples:
# Run comprehensive demonstration
python examples/example_hyperbolic_optimized.py
Examples include:
For more details, see examples/README.md
hyperbolic_solutions.csv, hyperbola_curves.csvhyperbolic_analysis.png (generated by analysis script)| Method | Candidates Tested | Best For |
|---|---|---|
| 6k±1 | 33% | General purpose, simple |
| Wheel-30 | 27% | Better performance |
| Wheel-210 | 23% | Maximum single-run performance |
| Miller-Rabin | Variable | Very large numbers |
| Hyperbolic (Optimized) ⭐ | 33% | Repeated queries, caching benefits |
For production use: Python recommended for performance-critical applications
Farid Masjedi
Contributions welcome! Areas of interest:
Open source - feel free to use, modify, and distribute.
For detailed usage instructions, see USER_GUIDE.md
For performance comparisons, see COMPARISON.md
For method explanations, see METHODS_GUIDE.md
FAQs
Comprehensive prime number utilities with multiple algorithms including the novel Hyperbolic Equation Method with intelligent caching
The npm package primefm receives a total of 0 weekly downloads. As such, primefm popularity was classified as not popular.
We found that primefm demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.