考虑 Fermat's Method:选取
Consider Fermat's Method: Choose
, compute . If with an integer, then . This can factor .
实际上就是要找一对整数
The idea is to find a pair of integers
satisfying
然后我们建立一个因子基,并随机
Then we build up a factor base, and randomly choose
, compute . After that, we use the factor base to factor and add the relation into a 01-matrix.
最后就是一次 01 矩阵求逆(这个矩阵很稀疏:一行中 1 元素不超过
The last step is to do an invert of the 01-matrix (This matrix is quite sparse: There're no more than
1 elements in a row), and multiply , we can get
实际上这个算法的时间复杂度是
The actual time complexity of this algorithm is
.
我们可以使用大素数:
We can use large primes:
isn't always easy to factor, so we use large primes to accelerate the speed. When we find two relations (called "partial relation") which contain the same large prime, we combine them into a relation that can be added into the factor base (called "full relation").
举例:分解
For example: Factorize
. We can get:
从最后一个式子我们得到
From the last equation we know
. So we perform and .
(其实,在实际生活中我们不会这么幸运,所以通常需要解一个很大的矩阵。)
(Actually, in real life we won't be such lucky, so we usually need to solve a large matrix.)