Skip to content

Add option for nth_prime() to be approximated#1002

Merged
bbayles merged 6 commits intomore-itertools:masterfrom
rhettinger:nth_prime_approx
Jun 24, 2025
Merged

Add option for nth_prime() to be approximated#1002
bbayles merged 6 commits intomore-itertools:masterfrom
rhettinger:nth_prime_approx

Conversation

@rhettinger
Copy link
Copy Markdown
Contributor

This makes nth_prime() usable with larger values of n.

% time python3.14 -c 'from more_itertools import nth_prime; nth_prime(100_000_000)' 
14.30s user 0.51s system 99% cpu 14.820 total

% time python3.14 -c 'from more_itertools import nth_prime; nth_prime(100_000_000, approximate=True)'
python3.14 -c   0.03s user 0.01s system 88% cpu 0.046 total

@rhettinger rhettinger changed the title Add an option for nth_prime() to be approximated Add option for nth_prime() to be approximated Jun 17, 2025
@bbayles bbayles merged commit 32dc427 into more-itertools:master Jun 24, 2025
6 checks passed
@rhettinger rhettinger deleted the nth_prime_approx branch June 27, 2025 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants