✨ feat(solutions/0009):添加欧拉项目第9题的解决方案
This commit is contained in:
18
solutions/0009/eular_9.py
Normal file
18
solutions/0009/eular_9.py
Normal file
@@ -0,0 +1,18 @@
|
||||
"""
|
||||
a^2 + b^2 = c^2
|
||||
a + b + c = 1000
|
||||
FIND a*b*c
|
||||
"""
|
||||
|
||||
|
||||
def euler_9():
|
||||
for a in range(1, 1000):
|
||||
for b in range(a, 1000):
|
||||
c = 1000 - a - b
|
||||
if a**2 + b**2 == c**2:
|
||||
print(f"Found a={a}, b={b}, c={c}")
|
||||
return a * b * c
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(euler_9())
|
||||
Reference in New Issue
Block a user