Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def long_sqrt(a):
- x = a
- while True:
- x1 = (x * x + a) // (2 * x)
- if x1 >= x:
- return x
- x = x1
- def factor(n):
- x = long_sqrt(n)
- while True:
- x += 1
- z = x * x - n
- c = long_sqrt(z)
- if c ** 2 - z == 0:
- return x - c, x + c
- f1 = open('input.txt', 'r')
- f2 = open('output.txt', 'w')
- n = int(f1.read())
- a, b = factor(n)
- f2.write(str(a) + '\n' + str(b))
- f1.close()
- f2.close()
Advertisement
Add Comment
Please, Sign In to add comment