Permalink
Switch branches/tags
Nothing to show
Find file Copy path
fe15a8b Jul 14, 2017
1 contributor

Users who have contributed to this file

27 lines (20 sloc) 527 Bytes
#
# Solution to Project Euler problem 39
# Copyright (c) Project Nayuki. All rights reserved.
#
# https://www.nayuki.io/page/project-euler-solutions
# https://github.com/nayuki/Project-Euler-solutions
#
def compute():
ans = max(range(1, 1001), key=count_solutions)
return str(ans)
def count_solutions(p):
result = 0
for a in range(1, p + 1):
for b in range(a, (p - a) // 2 + 1):
c = p - a - b # c >= b
if a * a + b * b == c * c:
result += 1
return result
if __name__ == "__main__":
print(compute())