Skip to content

Instantly share code, notes, and snippets.

@junichiro
Created February 1, 2018 03:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save junichiro/21a1c21761b17739c3b7c418bd313478 to your computer and use it in GitHub Desktop.
Save junichiro/21a1c21761b17739c3b7c418bd313478 to your computer and use it in GitHub Desktop.
会社で少し盛り上がった Project Euler をやってみる 009 ref: https://qiita.com/junichiro/items/51d23139d469d1196c2e
a^2 + b^2 = c^2
import sys
class Problem9:
def main(self, total):
for a in range(1, total - 1):
for b in range(a + 1, int((total - a) / 2) + 1):
c = total - a - b
if c ** 2 == a ** 2 + b ** 2:
return a * b * c
if __name__ == '__main__':
total = 1000
if len(sys.argv) == 2:
total = int(sys.argv[1])
p = Problem9()
print(p.main(total))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment