Shared pie

Algebra Level 2

At a party with 100 people, there is a pie. The first guest gets 1% of the pie, the second gets 2% of what is left, the third gets 3% of what is left and so on.

If the n n th guest gets the largest piece of all 100, what is n n ?


The answer is 10.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

19 solutions

Antoine G
Jun 10, 2018

Let f ( n ) f(n) be the fraction of the pie the n th n^{\text{th}} person gets. Then f ( n ) = n 100 i = 0 n 1 100 i 100 f(n) = \displaystyle \frac{n}{100} \prod_{i=0}^{n-1} \frac{100-i}{100}

Consider f ( n + 1 ) f ( n ) = 100 n 100 n + 1 n \frac{f(n+1)}{f(n)} = \frac{100-n}{100} \cdot \frac{n+1}{n} Then f ( n + 1 ) f ( n ) > 1 \frac{f(n+1)}{f(n)} >1 if and only if 100 n 100 n + 1 n > 1 ( 100 n ) ( n + 1 ) > 100 n 100 n n 2 > 0 \frac{100-n}{100} \cdot \frac{n+1}{n} > 1 \iff (100-n)(n+1) > 100 n \iff 100 - n -n^2 >0 Now one root of the polynomial 100 n n 2 100-n-n^2 is negative while the other is 9.512 \approx 9.512 . This means the ratio f ( n + 1 ) f ( n ) > 1 \frac{f(n+1)}{f(n)} >1 as long as n 9 n \leq 9 . So f ( n ) f(n) is increasing until it reaches n = 10 n=10 . After that it decreases.

Thus the 1 0 th \boxed{10^{\text{th}}} person gets the largest part of the pie.

Edit: f ( n ) = n 100 i = 0 n 1 100 i 100 f(n) = \displaystyle \frac{n}{100} \prod_{i=0}^{n-1} \frac{100-i}{100}

Francis Naldo - 3 years ago

Log in to reply

thanks! (otherwise it wouldn't work for n = 1 n=1 .)

Antoine G - 3 years ago

Couldn't have said it better myself!

Simon Rubin-Toles - 3 years ago

a plot of f ( n ) f(n) for reference:

Jose Fernandez Goycoolea - 2 years, 11 months ago

Log in to reply

Very nice!

Antoine G - 2 years, 11 months ago

Technically the maximum is between 9 and 10, so you would need to check both possibilities and see which one is higher. This is straightforward using the formula f ( n ) = n ! ( 99 n 1 ) 10 0 n f(n)=\frac{n! \binom{99}{n-1}}{100^n}

John Ross - 2 years, 11 months ago

Log in to reply

I don't think you need to check both. The fact that the solution is approximately 9.5 (not an integer) means that the ratio f ( n + 1 ) / f ( n ) f(n+1)/f(n) is never equal to 1. This means it is either < 1 <1 oder > 1 >1 . This translates into the fact that there is only one maximum value. Since it is precisely > 1 >1 when n 9 n \leq 9 , this means the maximum is at n = 10 n=10 .

Antoine G - 2 years, 11 months ago

Log in to reply

Ah, I see that I was wrong about checking both cases. I was thinking in terms of f ( n + d n ) / f ( n ) > 1 f(n+dn)/f(n)>1 (i.e. continuous) instead of f ( n + 1 ) / f ( n ) > 1 f(n+1)/f(n)>1 (i.e. discrete). I was incorrectly associating f ( n + 1 ) / f ( n ) > 1 f(n+1)/f(n)>1 with a positive continuous slope instead of a positive discrete slope.

John Ross - 2 years, 11 months ago

I have this habit of making exactly three mistakes on my way to finding a solution, so I didn't get the chance to share my solution. I plotted the function f(n)=n*((99!/(100-n)!))/(100^n), and although it isn't nearly as beautiful or simple as your solution (and is a lot more circuitous than just plotting a recursive function), I haven't seen it mentioned yet.

Binky MH - 2 years, 11 months ago

Log in to reply

well Jose Fernandez Goycoolea (see below) made a plot too). But he did not post it as a solution....

Antoine G - 2 years, 11 months ago

Log in to reply

It was less the plot I was talking about, and more the use of this type of function.

Binky MH - 2 years, 11 months ago

I did something similar, but I was observing when is f(n+1) - f(n) > 0. This leads to the same quadratic equation, which again gives n=9, so f(10) > f(9), and this n is the biggest such that f(n+1)-f(n) is true.

Adrian Mišak - 2 years, 11 months ago

Log in to reply

Yes, the two ideas are equivalent (as long as f ( n ) > 0 f(n) > 0 ): f ( n + 1 ) f ( n ) > 1 f ( n + 1 ) > f ( n ) f ( n + 1 ) f ( n ) > 0 \frac{f(n+1)}{f(n)} > 1 \iff f(n+1) > f(n) \iff f(n+1) - f(n) > 0 so it's normal that you get to the same equation. I don't know why I chose my starting point (rather than yours), it's a question of taste I suppose...

Antoine G - 2 years, 11 months ago

Just a question please.. the answer of course is 10 with a piece size around “6.281565”. I know it is not 2π exactly... but it is close to that. Is that just a coincidence? Thanks

Ivan Sivak - 2 years, 10 months ago

Log in to reply

For the 2 π 2 \pi , I'm pretty sure it's a coincidence. But it might depend on how you wish to extend the problem when there are more than 100 persons.

Here would be my choice: you have N N persons; the 1st gets 1 N \frac{1}{N} of the pie, the 2nd 2 N \frac{2}{N} of what remains, etc...

The solutions goes as above with N N in place of 100. The person with the biggest chunk will be (unless 1 + 4 N \sqrt{1+4N} is an integer) n N = 1 + 4 N 1 2 + 1 n_N = \lfloor \frac{ \sqrt{1+4N} -1 }{2} \rfloor +1 . The size of his chunk will be given by evaluating f ( n ) = n N i = 0 n 1 N i N f(n) = \frac{n}{N} \prod_{i=0}^{n-1} \frac{N-i}{N}
at n N n_N .

Now the values of f ( n N ) 0 f(n_N) \to 0 . What is interesting is that f ( n N ) 0.6065306... N f(n_N) \approx \frac{0.6065306... }{ \sqrt{N} } . I think the 0.6065306... 0.6065306... should be e 1 / 2 e^{-1/2} , but I just checked it numerically.

You can try to prove it! ... or ask this as a question to the community.

Hint: Note that the easiest case is N = 1 0 2 k N = 10^{2k} then n N = 1 0 k n_N = 10^k and so N f ( n N ) = i = 0 1 0 k 1 1 i 1 0 2 k \sqrt{N} \cdot f(n_N) = \prod_{i=0}^{10^k-1} 1- \frac{i}{10^{2k}} More generally for N N large, N f ( n N ) = i = 0 N 1 1 i N \sqrt{N} \cdot f(n_N) = \prod_{i=0}^{\sqrt{N}-1} 1- \frac{i}{N}

TLDR I think this is related to e e but not to π \pi , but you only see this if you go far out in the sequence.

Antoine G - 2 years, 10 months ago
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#https://brilliant.org/weekly-problems/2018-06-18/advanced/?p=2
left = 100.0 # %
largest_piece = 0
largest_n = 0

for p in range(1,101):  # n --> 1 to 100
    left_prev = left
    left -= left*p/100.0
    if left_prev-left > largest_piece:
        largest_piece = left_prev-left
        largest_n = p
    else:
        break
print 'n = %d; Percentage of whole pie = %0.10f%%' %(largest_n, largest_piece)

1
n = 10; Percentage of whole pie = 6.2815650956%

note that you can terminate the search early

Mike Pannekoek - 2 years, 11 months ago

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
Up to and including n = 10 each successive one gets a larger % after which each successive % -> 0. Search can be terminated when % start decreasing
n = 1; Percentage of whole pie = 1.0000000000%
n = 2; Percentage of whole pie = 1.9800000000%
n = 3; Percentage of whole pie = 2.9106000000%
n = 4; Percentage of whole pie = 3.7643760000%
n = 5; Percentage of whole pie = 4.5172512000%
n = 6; Percentage of whole pie = 5.1496663680%
n = 7; Percentage of whole pie = 5.6474674502%
n = 8; Percentage of whole pie = 6.0024511185%
n = 9; Percentage of whole pie = 6.2125369077%
n = 10; Percentage of whole pie = 6.2815650956%

Michael Fitzgerald - 2 years, 11 months ago

whats the time and space complexity of your solution to the problem?

Shashank Rustagi - 2 years, 11 months ago

Log in to reply

Storage space is constant, i.e. O(1). Time is linear, i.e. O(N). The loop is continued all the way to p=100.

In principle this code would work for any arbitrary sharing function, and it could be optimized to terminate when the remainder of the cake is less than the biggest piece, which in this case would occur at p=23, which would make it a bit faster. For this "linear" sharing function, as mentioned below, it is quite easy to show that the search can be terminated when the size of the pieces starts to decrease (at p=11).

Roland van Vliembergen - 2 years, 11 months ago

This looks like cheating! XD

Mykyta Shvets - 2 years, 11 months ago

Let f ( n ) f(n) be the fraction of the pie n t h n^{th} person gets. Let 1 denote the amount of pie in the starting.

So, f ( n ) = n 100 ( 1 i = 1 n 1 f ( i ) ) f(n) = \displaystyle\frac{n}{100}\Bigg(1 - \sum_{i=1}^{n-1}f(i)\Bigg) for n 2 Eq. 1 n \geq 2 \qquad\qquad\dots \text{Eq. 1}

Also, f ( n ) = i = 1 n f ( i ) i = 1 n 1 f ( i ) Eq. 2 f(n) = \displaystyle\sum_{i=1}^{n}f(i) - \sum_{i=1}^{n-1}f(i)\qquad\qquad\dots\text{Eq. 2} .

Using Eq. 1 in Eq. 2 , we get

f ( n ) = 100 ( f ( n ) n f ( n + 1 ) n + 1 ) f ( n + 1 ) f ( n ) = ( 100 n ) ( n + 1 ) 100 n f(n) = 100\Bigg( \frac{f(n)}{n} - \frac{f(n+1)}{n+1}\Bigg) \Rightarrow \frac{f(n+1)}{f(n)} = \frac{(100-n)(n+1)}{100n}

Now we have to find maximum value of n n such that f ( n + 1 ) f ( n ) f(n+1) \geq f(n) i . e . f ( n + 1 ) f ( n ) 1 i.e. \ \frac{f(n+1)}{f(n)} \geq 1

( 100 n ) ( n + 1 ) 100 n 1 \Rightarrow \frac{(100-n)(n+1)}{100n} \geq 1 ( 100 n ) ( n + 1 ) 100 n n 2 + n 100 0 \Rightarrow (100-n)(n+1) \geq 100n \Rightarrow n^2 + n - 100 \leq 0

The positive root of this equation 9.51 \approx 9.51 . So maximum value of n n can be 9 9 .

And so, f ( 10 ) f ( 9 ) f(10) \geq f(9) . Hence 1 0 th 10^{\text{th}} person will get the largest piece of pie.

You didn't write the base case for the above defined recursive function. f(1) = 0.01

Tehillah _ - 2 years, 11 months ago
Cl Chong
Jun 21, 2018

I got lazy at deriving formula, so I used excel. Column A as guest number, Column B (amount of pie) and C (pie remaining) with formulas as shown, and dragged the them down all the way to 100th guest, and plotted graph, to reach answer -->10

Alex Jones
Jun 18, 2018

Bashed with a calculator. Trivial.

Dang, I wish I was as good as you.

Alexander Koran - 2 years, 11 months ago

Math meme comment. Trivial as well.

Lukas Henke - 2 years, 11 months ago
Vinod Kumar
Jun 19, 2018

When it is the turn of number m, a certain part, 'r', of the pie is left.

Person number m gets 'r' multiplied by (m/ 100), i.e.

= r*(m/100)

which is the formula for m per cent of 'r', and the amount of pie left is

= r *(100-m)/100.

When it comes to the turn of the next person m + 1, he will get

= r* ((100-m)/100)* ((m+1)/ 100).

Therefore person m+1 gets more than person m, if

(100-m)/100)* ((m + 1)/100) > m/100.

This reduced to the inequality

100 - m- m^2 > 0 ,

is true for m = 1, 2...., up to 9.

In other words, the amount of pie taken by each person keeps on increasing until the 9th person , but from the 10th person and beyond the amount is smaller.

Therefore, we conclude , number 10 gets the largest amount.

This above solution is discussed for the same puzzle which appeared recently in Guardian paper.

Brian Rich
Jun 23, 2018

Solution 1

Some Haskell code. (Type annotations omitted for space and not needed since Haskell has type inference).

1
2
3
4
5
6
7
8
import Data.List (maximumBy)
import Data.Ord (comparing)

main = print result
result = snd $ maximumBy (comparing fst) $ zip (map (f 100) [1..100]) ([1..100])
-- The fraction of the pie received when there are `n` people, the first
--  getting `1 / n` of the whole, and the `i`th getting `i / n` of what remains.
f n i = (i / n) * product [ 1 - (j / n) | j <- [1..(i-1)] ]

Output:

1
10

Solution 2

Let f ( j ) f(j) be the fraction of the pie received by the j j th person. Then we have f ( j ) = g ( j ) h ( j ) f(j) = g(j) h(j) , where

g ( j ) = i = 1 j 1 ( 1 j 100 ) h ( j ) = j 100 \begin{aligned} g(j) & = \prod^{j-1}_{i=1} \left( 1 - \frac{j}{100} \right) \\ h(j) & = \frac{j}{100} \end{aligned}

Let Δ \Delta denote the finite difference operator. Then Δ f ( j ) = g ( j ) Δ h ( j ) + Δ g ( j ) h ( j + 1 ) \Delta f(j) = g(j) \Delta h(j) + \Delta g(j) h(j+1) . Since Δ h ( j ) = 1 100 \Delta h(j) = \frac{1}{100} and

Δ g ( j ) = g ( j + 1 ) g ( j ) = g ( j ) ( 1 j 100 1 ) = j 100 g ( j ) , \begin{aligned} \Delta g(j) & = g(j+1) - g(j) \\ & = g(j) \left( 1 - \frac{j}{100} - 1 \right) \\ & = - \frac{j}{100} g(j), \\ \end{aligned}

we have that g ( j ) Δ h ( j ) + Δ g ( j ) h ( j + 1 ) = 1 100 g ( j ) j 100 j + 1 100 g ( j ) = [ 1 100 j 2 + j 10000 ] g ( j ) \begin{aligned} g(j) \Delta h(j) + \Delta g(j) h(j+1) & = \frac{1}{100} g(j) - \frac{j}{100} \frac{j+1}{100} g(j) \\ & = \left[\frac{1}{100} - \frac{j^2 +j}{10000} \right] g(j) \\ \end{aligned}

Since g ( j ) g(j) is positive, we have [ 1 100 j 2 + j 10000 ] g ( j ) > 0 \left[\frac{1}{100} - \frac{j^2 +j}{10000} \right] g(j) > 0 when 1 100 > j 2 + j 10000 \frac{1}{100} > \frac{j^2 +j}{10000} , or equivalently 1 > j 2 + j 100 1 > \frac{j^2 + j}{100} , or equivalently 100 > j 2 + j 100 > j^2 + j . When j j is restricted to be an integer, this happens precisely when j < 10 j < 10 , so j = 10 j = 10 is the first integer at which Δ f \Delta f is decreasing. This tells us immediately that n = 10 n = 10 , since all values of f ( j ) f(j) with j < 10 j < 10 are smaller since f f is increasing on them and all values of f ( j ) f(j) with j > 10 j > 10 are smaller since f f is decreasing on them.

James Long
Jun 21, 2018

i uh... just wrote a matlab code... is that cheating?

pie(1)=100;

for i=1:100

cut(i)=i/100;

cutofpie(i)=pie(i)*cut(i);

pie(i+1)=pie(i)-cutofpie(i);

end

max(cutofpie) %now look in the variable cutofpie for the entry at which the max value is in.

John Finch
Jun 19, 2018

I did exactly the same :)

Jon Treby - 2 years, 11 months ago
Alex Waldherr
Jun 23, 2018

If we simplify the problem and think about ten guest, who's proportions increase by 10% instead of 1% of what's left, calculate how much each of those gets and plot it, we get the brown function. Its maxima is at around 30% so the third guest gets the biggest part. When we decrease the percentage to 5% (red line) and in the end to 1%, we see that the maxima shifts, as more stuff is taken from the cake in the beginning and therefore sooner less is left. Therefore the maxima, where the percentage is big enough to get more than the person before, but the cake is still large enough to not outweigh the increase in percentage, is shifted to the left. To about 10%. That is why the tenth person gets the most cake with 0,628% of the total cake.

THIS "big" piece of cake would leave me still hungry ;)

Sam Marrell
Jun 21, 2018

I used Excel, set up the following way: ||Guest #||Share||Pie Remaining|| ||1||=A2 A2/100||=1-B2|| ||2||=(C2 A3/100)||=C2-B3|| ... ||100||=(C100*A101/100)||=C100-B101|| |

Azeez Daoud
Jun 21, 2018

Graphing can also be used to solve this problem.

Let f ( x ) = n = 1 x 1 n 100 \displaystyle f(x)=\prod_{n=1}^{x}1-\frac{n}{100}

A plot of this function: Source: https://www.desmos.com/calculator/w8o7mdfuc2 Source: https://www.desmos.com/calculator/w8o7mdfuc2

Let j ( x ) = f ( x 1 ) f ( x ) j(x) = f(x-1)-f(x)

The function j ( x ) j(x) shows the difference between two consecutive values. The peak of the graph of the function j ( x ) j(x) shows the number of the guest that took the largest piece of the pie.

The plot of the function j ( x ) = f ( x 1 ) f ( x ) j(x) = f(x-1)-f(x) : Source: https://www.desmos.com/calculator/w8o7mdfuc2 Source: https://www.desmos.com/calculator/w8o7mdfuc2

The peak of the graph is at 10 10 and thus the 10 10 th person is the one who took the largest piece of the pie. The answer is 10 \fbox{10} .

NOTE: Both function are not continuous and that is why they are "cut" between each whole number.

Six Sandlava
Jun 20, 2018

Here's a wicked and intuitive way to figure out this problem!

Consider the following as if it were a new problem:

1. For the first few n n , each slice of pie will be just slightly less than n n % of the pie in size.

2. The size of each slice of pie will only start to decrease when half the pie has been eaten.

Given this, how many slices do we eat before half the pie is gone?

For complicated reasons, the simplified logic of the new problem illustrated here holds when applied to the main problem. Good luck!

Griffin Trayner
Jun 20, 2018

We can model the amount of pie left after x people take their share with a recursive function:

f(x) = f(x-1) - f(x-1)*(x/100), f(0) = 1.

This can be simplified to this:

f(x) = (f(x-1)(100-x))/100

If we extend this function out, evaluating it at f(1),f(2), etc., then you notice a pattern develops:

f(x) = (99!/(100-x)!)*(1/100^(x+1))

If you want to find out how much x person takes, simply multiply the amount of pie by the persons number over 100:

f(x) = 99!/((100-x)!*100^x)

Plugging this into desmos (I know this is cheating), the maximum is at x=10.

Lovro Cupic
Jun 20, 2018

Notice that 2nd person gets bigger piece of pie than 1st and so on, until n+1th person gets smaller amount of pie than n-th. Let's naively set up an equation where two consecutive people get equal amounts: first of them gets p of the (remaining) pie, and second (p+0.01)(1-p) of it. p = p - p^2 + 0.01 - 0.01p which yields p = 0.095. It's easy to check that 10th person gets more than 9th (11th) person.

Torus Wheel
Jun 19, 2018

Using Python 3.6:

Michele Abruzzese
Jun 19, 2018
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
class CakePartition {

    public static void main(String args[]) {

        double cake = 100;
        int person = 1;
        double maxQuantity = 0;
        for (int i=1; i<=100; ++i) {
            double quantity = i*cake/100.0;
            cake -= quantity;
            if (quantity > maxQuantity) {
                maxQuantity = quantity;
                person = i;
            }
        }
        System.out.println("PERSON No: " + person + ", QUANTITY (%): " + maxQuantity);
    }
}

1
PERSON No: 10, QUANTITY (%): 6.2815650955529465

Benny Joseph
Jun 19, 2018
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
<?php
$value = array(0.00,0.01);

for($i=2;$i<101;$i++){
$next = $i*(1-array_sum($value))/100    ;
array_push($value,$next);
}
//print_r($value);
echo 'Maximum value is '.max($value).'<br>';
echo 'Maximum value occurs at person no '.array_search(max($value), $value).'';
//check if sum of all values is 1
//print_r(array_sum($value));
?>

1
2
Maximum value is 0.062815650955529
Maximum value occurs at person no 10

Si T
Jun 18, 2018

Here is an Excel solution:

Let’s assume this pie has a total amount of 100. The actual unit doesn’t matter.

In cells A1 through A100, enter numbers 1 through 100. Column A represents n.

In cell B1, enter: =(A1/100)*100

In cell B2, enter: =(A2/100)*(100-SUM($B$1:B1))

Copy cell B2 and paste into cells B3 through B100. Column B represents the amount of pie the corresponding nth person will get.

You will find that at n=10, the amount in cell B10 is the highest at 6.2816. This means the 10th person, or n = 10, gets the most pie.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...