Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from math import sqrt
- def sol_equa(n):
- LIMIT = 1000
- solutions = list()
- for y in range(1, LIMIT):
- for x in range(y, LIMIT):
- if x**2 - 4 * y**2 == n:
- solutions.append([x, y])
- return solutions
- def sol_equa2(n):
- solutions = list()
- for y in range(1, 50000):
- x_squared = 4 * y**2 + n
- if sqrt(x_squared) == int(sqrt(x_squared)):
- solutions.append([int(sqrt(x_squared)), y])
- return solutions
- # MAIN FUNCTION
- print(sol_equa(5))
- print(sol_equa(21))
- print(sol_equa2(90005))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement