Factorization of large numbers

In the class, we found this programming problem, and currently we have no idea how to solve it.

A positive integer is given n. It is known that n = p * q, where pand qare strokes, p<=qand |q-k*p|<10^5for some given positive integer k. You must find pand q.

Input:

35 1
121 1
1000730021 9

Output:

5 * 7
11 * 11
10007 * 100003

This is not homework, we are just trying to solve some interesting problems. If you have any ideas, post them here so we can try something, thanks.

+5
source share
4 answers

, , (), , , - .

. , Google " ", " ", " ", " ", " " " ". () . , , , , , - 110 , MPQS , , , GNFS , , ( , , , ).

+2

ECM . . , , , , . , : GMP-ECM C/++ Pyecm Python.

$ python
>>> import math
>>> import pyecm
>>> n = 1000730021
>>> list(pyecm.factors(n, False, False, 2 * math.log(math.log(n)), 1.0))
[10007, 100003]
+2
n = p * q 
|q-k*p|<10^5

n k .

q-k*p=a 

-10^5<=a<=10^5

q-k*p=a q p*q n,

q^2-a*q-k*n=0

a

-10^5<=a<=10^5` 

, q n. , 2*10^5+1. n k, n k, .

, ,

a^2+4*k*n

- .

+1

n = p * q | q-k * p | < 10 ^ 5 n k, . q-k * p = a, -10 & bull; 5 <= < = 10 & bull; 5 q-k * p = a q ans, p * q n, ^ 2- * - * = 0. a -10 ^ 5 <= a <= 10 ^ 5 , q n. , 2 * 10 ^ 5 + 1. n k

p

[(sqrt(k*n+2500000000)-50000)/k,(sqrt(k*n+2500000000)+50000)/k]

10 ^ 5/k p. q

[sqrt(k*n+2500000000)-50000,sqrt(k*n+2500000000)+50000]

10 ^ 5-

0

All Articles