nishanth17 / factor Goto Github PK
View Code? Open in Web Editor NEWFast prime factorization in Python
Fast prime factorization in Python
A bug occured when the input number is 2152302898747
.
The program output 2152302898747^1
, while the real answer for this case is 6763^1 * 10627^1 * 29947^1
.
It seems to be related to the function is_prime
, Miller-Rabin primality-test Algorithm.
please fix all erros
The function factorize
has a bug, in particular, if asked to factorize 18846316186591 it returns 1097 as its sole factor.
However, if run with the verbose flag set, it works as expected. I'll try to find the reason if I have some time, it seems to be related to the Pollard Rho algorithm.
factorize(18846316186591)
[(1097, 1)]
>>> factorize(18846316186591, verbose=True)
Factoring 18846316186591...
Number of digits: 14
Finding small prime factors...
Prime factors found: 1097
Factoring 17179868903 with Pollard Rho...
Found factor 17179868903
Factoring 17179868903...
Number of digits: 11
17179868903 is prime!
[(1097, 1), (17179868903, 1)]
Should the construction of A in the Suyama parameterisation use modular inversion mod n of 4u**3*v instead of division
A = ((vmu * vmu * vmu) * (3 * u + v) / (4 * u * u * u * v) - 2) % n
should be
A = ((vmu * vmu * vmu) * (3 * u + v) * pow(4 * u * u * u * v,-1,n) - 2) % n
or an alternative modular inversion routine
I suspect the construction of (A+2)/4 and u ** 3/v ** 3 need to use modular inversion as well.
(Alternatively instead of x=u ** 3/v ** 3, z=1, you could have x=u ** 3, z=v ** 3)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.