Advertisement
danchaofan

Euler #75

Dec 26th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. from math import gcd
  2.  
  3.  
  4. def coprime(a, b, c):
  5.     return gcd(a, b) == 1 and gcd(a, c) == 1 and gcd(b, c) == 1
  6.  
  7.  
  8. sums, seen = [0]*1500001, []
  9. for x in range(1, int(1500000 ** 0.5 + 2)):
  10.     for y in range(x + 1, 10 ** 10):
  11.         if not coprime(x ** 2 + y ** 2, 2 * x * y, y ** 2 - x ** 2):
  12.             continue
  13.         total = 2 * y ** 2 + 2 * x * y
  14.         for z in range(1, 10 ** 10):
  15.             new_total = total * z
  16.             if new_total > 1500000:
  17.                 break
  18.             sums[new_total] += 1
  19.         if total > 1500000:
  20.             break
  21. print(sums.count(1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement