Created
October 4, 2020 17:56
-
-
Save itdxer/33f94dc1395ad2cc54bcb612c798dd30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from itertools import combinations | |
primes = [2, 2, 2, 5, 5, 7] | |
number = 1400 | |
assert np.prod(primes) == number # sanity check | |
observed_sets = set() | |
n_hips = 0 | |
for i in range(1, len(primes)): | |
for subset in combinations(primes, i): | |
x = np.prod(subset) | |
y = number // x | |
if x < y and x not in observed_sets : | |
observed_sets.add(x) | |
if (y - x) % 2 == 0: | |
b = (y - x) // 2 | |
a = b + x | |
assert (a**2 - b**2) == number, a**2 - b**2 # sanity check | |
print(f"a={a}, b={b}") | |
n_hips += 1 | |
print(f"Number of hips: {n_hips}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment