Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quadratic sieve factoring #161

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

oscardssmith
Copy link
Member

@oscardssmith oscardssmith commented Dec 15, 2024

After being heavily nerd-sniped by @s-celles, here is a quadratic sieve implementation. It's already a good bit faster than my ECM implementation in #104 for semi-primes (and there still is some relatively low hanging fruit for further optimization, specifically looking for x^2 - m*N and using multiple polynomials). Unfortunately for factoring big numbers with lots of factors it's fairly slow (so probably needs combining with ECM with a low bound)

julia> x = prod(nextprime(big(2)^30, i) for i in 1:2)
1152921515344265237

julia> @time Primes.QSfactor(x)
  0.006857 seconds (25.64 k allocations: 1.795 MiB)

julia> x = prod(nextprime(big(2)^50, i) for i in 1:2)
1267650600228402790082356974917

julia> @time Primes.QSfactor(x)
  0.592893 seconds (353.31 k allocations: 55.101 MiB, 4.61% gc time)

julia> x = prod(nextprime(big(2)^30, i) for i in 1:4)
1329228037874877665163654221879315219

julia> @time Primes.QSfactor(x)
  5.168209 seconds (1.19 M allocations: 313.809 MiB, 0.56% gc time)

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.

1 participant