n = 69189629845368937640576720662244866511517654267613033786225538055857304509
# X is the upper bound on the value of the prime we are looking for
X = 2^(123-83)
# This is the value of p_t given in the exercise; for consistency with earlier exercises, we rename this to a.
a = 7975367974709495237422842361682067456
M_1 = matrix([
[X^2, a*X, 0],
[0, X, a],
[0, 0, n]
])
B_1 = M_1.LLL()
Q_1 = B_1[0][0]*x^2/X^2 + B_1[0][1]*x/X + B_1[0][2]
Q_1.roots(ring=ZZ)
[(101320256243, 1)]
p = a + Q_1.roots(ring=ZZ)[0][0]
p
7975367974709495237422842463002323699
p.is_prime()
True
p.divides(n)
True
# We also should compute the remaining factor of n
q = n/p
q
8675415361996408337581654026937922191
q.is_integer()
True
q = Integer(q)
q.is_prime(), q.divides(n)
(True, True)
p * q == n
True
Mod(p, 2^40)
101320256243