// you’re reading...
1 Star2 Stars3 Stars4 Stars5 Stars (3 votes, average: 5.00 out of 5)

Solutions 151 - 200

Project Euler 183 Solution

Project Euler 183 Solution

Project Euler 183: Maximum product of parts

Problem Description

Let N be a positive integer and let N be split into k equal parts, r = N/k, so that N = r + r + … + r.
Let P be the product of these parts, P = r × r × … × r = rk.

For example, if 11 is split into five equal parts, 11 = 2.2 + 2.2 + 2.2 + 2.2 + 2.2, then P = 2.25 = 51.53632.

Let M(N) = Pmax for a given value of N.

It turns out that the maximum for N = 11 is found by splitting eleven into four equal parts which leads to Pmax = (11/4)4; that is, M(11) = 14641/256 = 57.19140625, which is a terminating decimal.

However, for N = 8 the maximum is achieved by splitting it into three equal parts, so M(8) = 512/27, which is a non-terminating decimal.

Let D(N) = N if M(N) is a non-terminating decimal and D(N) = -N if M(N) is a terminating decimal.

For example, ΣD(N) for 5 ≤ N ≤ 100 is 2438.

Find ΣD(N) for 5 ≤ N ≤ 10000.

Project Euler 183 Solution

Runs < 0.010 seconds in Python 2.7.
download arrowUse this link to get the Project Euler 183 Solution Python 2.7 source.


Slowly swipe from either end beginning with the white vertical bar to get an idea of the starting or ending digits. For less drama, just double click the answer area. The distance between the two bars will give you an idea of the magnitude. Touch devices can tap and hold the center of the box between the two bars and choose define to reveal the answer.


  • The value of k that maximizes P as M(N) (or Pmax) can be calculated as N/e. Where e is 2.718281828, the base of the natural logarithm.
  • As for determining D(N): A fraction will terminate if and only if the denominator, k, has for prime divisors only 2 and 5, that is, if and only if the denominator has the form 2n5m for some exponents n ≥ 0 and m ≥ 0. The number of decimal places until it terminates is the larger of n and m.


No comments yet.

Post a comment