Skip to content

Commit c5c5752

Browse files
Update sol1.py
1 parent d93526f commit c5c5752

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

project_euler/problem_190/sol1.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,18 @@
55
66
Let S_m = (x_1, x_2, ..., x_m) be the m-tuple of positive real numbers with
77
x_1 + x_2 + ... + x_m = m for which P_m = x_1 * x_2^2 * ... * x_m^m is maximised.
8-
For example, it can be verified that |_P_10_| = 4112
9-
(|__| is the integer part function).
10-
Find Sum_{m=2}^15 = |_P_m_|.
8+
9+
For example, it can be verified that |_ P_10 _| = 4112
10+
(|_ _| is the integer part function).
11+
12+
Find Sum_{m=2}^15 = |_ P_m _|.
1113
1214
Solution:
1315
- Fix x_1 = m - x_2 - ... - x_m.
1416
- Calculate partial derivatives of P_m wrt the x_2, ..., x_m. This gives that
1517
x_2 = 2 * x_1, x_3 = 3 * x_1, ..., x_m = m * x_1.
1618
- Calculate partial second order derivatives of P_m wrt the x_2, ..., x_m.
1719
By plugging in the values from the previous step, can verify that solution is maximum.
18-
19-
>>> solution(5)
20-
10
21-
2220
"""
2321

2422

@@ -32,7 +30,8 @@ def solution(n: int = 15) -> int:
3230
2
3331
>>> solution(4)
3432
4
35-
33+
>>> solution(5)
34+
10
3635
"""
3736

3837
ans = 0

0 commit comments

Comments
 (0)