Skip to content

Commit df249f2

Browse files
Update sol1.py
1 parent 2ee900c commit df249f2

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

project_euler/problem_190/sol1.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,15 @@ def solution(n: int = 15) -> int:
3333
>>> solution(5)
3434
10
3535
"""
36-
37-
ans = 0
36+
total = 0
3837
for m in range(2, n + 1):
3938
x1 = 2 / (m + 1)
40-
capital_p = 1.0
39+
p = 1.0
4140
for i in range(1, m + 1):
4241
xi = i * x1
43-
capital_p *= pow(xi, i)
44-
ans += int(capital_p)
45-
return ans
42+
p *= xi ** i
43+
total += int(p)
44+
return total
4645

4746

4847
if __name__ == "__main__":

0 commit comments

Comments
 (0)