File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed
project_euler/problem_190 Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change 55
66Let S_m = (x_1, x_2, ..., x_m) be the m-tuple of positive real numbers with
77x_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
1214Solution:
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
You can’t perform that action at this time.
0 commit comments