A shopkeeper has an excellent recycling policy:
You have $59049 with you. What is the maximum number of chocolates that you can buy?
Extra Credit: Try to derive a generalized expression for the number of chocolates you can buy with $n.
Details and Assumptions:
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.
well I can use gp series formula.. 59049+59049/3+59049/9+59049/27...upto infinity=88573 chocolates.
Log in to reply
Try doing it for four dollars and figure out where you went wrong.
Here is another general solution by @bobbym none :
4 1 ( 6 n − ( − 1 ) n − 3 )
chocolates bought (n)= 3+ 2m +n(mod 2) where, m is the free chocolates. Adding n+m, we get the value of total chocolates we get. Am I wrong?
Log in to reply
What is the relation between m and n?
Log in to reply
I worked on it and found out it should be- Money OR Chocolates bought can be of the form
Money= 3 + 2(Free Chocolates) + (Money-3)mod 2.
So ,Adding Money +Free Chocolates will give You What You Get(total).
Every dollar buys 1 chocolate. Each chocolate buys 1/3 of another chocolate. That 1/3 chocolate buys another 1/3 chocolate, and so on. So each dollar buys 1 + 1/3 + 1/9 + 1/27....
We can use the infinite geometric series formula to find that each dollar buys 1/(1-1/3) or 1/(2/3) or 3/2 chocolate bars.
Since he has $59049 dollars he can buy 59049 *1.5 which is 88,573.5. However, you cannot buy half of a chocolate bar so round down to 88,573.
This is incorrect. Just test what happens when you have 4 dollars initially.
Log in to reply
You would get 4*1.5=6 chocolates. Round 6 down, and you get 5 chocolates, which is the answer.
Log in to reply
What justifies you to round down 6 to 5?
Log in to reply
@Ivan Koswara – Rounding should be carried out every time, unlike the reasoning by Dominick Hing which says "However, you cannot buy half of a chocolate bar so round down"
So example you have $10. 10*1.5=15
15 rounded down is 14
Ans: You could get 14 chocolates with $10
If you have $45
45 times 1.5=67.5
67.5 rounded down is 67
Ans: You could get 67 chocolates with $45
etc.
so the formula should be, if you have $n , you could buy k chocolates, where k is the largest integer that is strictly smaller than (1.5*n). This is slightly different from the floor function of (1.5n), because if 1.5n is an integer you are still supposed to round it down.
Log in to reply
@Lee Isaac – Yes, you have specified how to round down, but you haven't justified why.
Log in to reply
@Ivan Koswara – Oh. Sorry. You have to round down because when using the formula 1.5n, you will always get a bigger answer than when you actually calculate the number of chocolates by dividing by three and stuff. 3 1 + 9 1 + 2 7 1 + 8 1 1 + 2 4 3 1 + . . . APPROACHES 2 1 but never actually reaches it. This proves that 1.5n will always be bigger than when you calculate by taking into account the wrappers and dividing by 3.
This proof is somewhat incomplete, I also have to prove that
0 < 1 . 5 n − a c t u a l a n s w e r ≤ 1
I'm not sure how to do this, can someone enlighten us?
@Dominick Hing What's the infinite geometric series formula?
This problem is essentially the infinite geometric series 3 0 + 3 − 1 + 3 − 2 . . . and problems like this can be solved like this:
For a series n 0 + n − 1 + n − 2 + n − 3 . . . the sum (found limit of series) is n − 1 n . If the series is of this form but finite, find the theoretical infinite sum, then floor it (round down)
In this case, it's 2 3 that you're multiplying by.
Floor function is not good enough. If you had $4, using floor function, you would get 6 chocolates, which is wrong. You should only get 5 chocolates. You have to round down even if the number of chocolates is an integer.
chocolate cost = D = $1
you have A = $59,049
you can buy A/D = 59,049 bars
you get x =1 extra bars for recycling y = 3 wrappers
but each bar has z = 1 wrappers
so Az/Dy = 59,049z/3 = +19683
those 19683 will give you an extra 6561
which gives you an exta 2187
which gives you an extra 729
which gives you an extra 243
which gives you an extra 81
which gives you an extra 27
which gives you an extra 9
which gives you an extra 3
which gives you an extra 1
final answer 88573
in this particular case, where you get 1 chocolates for 3 wrappers, we can just use the formula below,
using the first formula, 3*59049 - 1 = 177146, 177146/2 = 88573
where N->amount of money. r->1/no. of wrappers for on chocolate.
and yes you can simplify the formula as u like
Here is the VB.NET code I used:
Module Module1
Sub Main()
Dim money As Integer = 59049
Dim chocolates As Integer = 0
Dim wrappers As Integer = 0
While Not money = 0
money = money - 1
chocolates += 1
wrappers += 1
If wrappers = 3 Then
chocolates += 1
wrappers = 1
End If
End While
Console.WriteLine(chocolates)
Console.ReadLine()
End Sub
End Module
I did it in QB64 since that's the only language I know so far :( anyways the idea is to create a function, subroutine, or loop that calculates 59049 + 59049/3 +59049/3/3...etc until it reaches 1 (we can assume the answer is an integer).
Python:
1 2 3 4 5 6 7 8 9 10 11 12 |
|
You will buy 59049 chocolates with $59049 and then you will have 59049 wrappers. Then with 59049 wrappers, you can buy another 19683 chocolates and with 19683 wrappers you can...
Using the info, you can form a equation and solve -
x = 5 9 0 4 9 + 3 5 9 0 4 9 + 9 5 9 0 4 9 … 3 x = 3 5 9 0 4 9 + 9 5 9 0 4 9 + 2 7 5 9 0 4 9 … x − 3 x = 5 9 0 4 9 + 3 5 9 0 4 9 − 3 5 9 0 4 9 + 9 5 9 0 4 9 − 9 5 9 0 4 9 + 2 7 5 9 0 4 9 − 2 7 5 9 0 4 9 … x − 3 x = 5 9 0 4 9 x = 8 8 5 7 3
it forms an AP like for 3$ - 4 ,5$-7 ,7$-10 so on which is 3$ is first term so add 1 to 3 then for 5$ it s second term so add 2 to 5 so find the position of 59046$ and add it to the amount
What i did was take the amount of money 59049. That would get you 59049 chocolates. Since each one comes wrapped, divide that by 3 to get the number of chocolates you would get from the wrappers, then divide that number by 3 to get another numbrer. keep doing this until you get to one, and then add up all your solutions. 59049+19683+6561+2187+729+243+81+27+9+3+1 for a total of 88573
Essentially, you have two values of candies: the number of chocolates from the initial purchase and the number of chocolates through wrapper trade in. Summing these two values will give you the total number of chocolates. To find the latter value, you must create a summation expression to find the value.
After purchasing the initial amount of chocolate, the number of chocolate you get from the shopkeeper via trade-in becomes: 3 5 9 0 4 9 The wrappers from the trade-in chocolate can also be used to obtain more chocolate. That number is simply: # chocolate received from trade-in / 3 As we continue with this process, we can easily see that this whole process can be expressed as: 3 n 5 9 0 4 9 Now that we know this function, the next question we ask ourselves is what is the upper bound. If n is too large, the resulting number from our function becomes a fraction, which we do not want. Thus, in order to find a sufficient n, we simply perform a logarithmic operation to obtain n. The operation is: l o g 3 5 9 0 4 9 = n n = 1 0 Now that we have these numbers, we can easily use a summation operation to get the total number of chocolates obtained by the wrapper trade-in policy. Thus: i = 1 ∑ 1 0 3 n 5 9 0 4 9 Solving the summation will give us 29524. Going back to the first part, we add that number to 59049 to get the total number of chocolates obtained, 88573.
Regarding the last summation operation, the value "i" should be "n" and the 1 on the top should be a ten. Somehow my formatting messed up the upper bounds. Edited Summation: n = 1 ∑ 1 0 3 n 5 9 0 4 9
chocolate cost = D = $1 you have A = $59,049 you can buy A/D = 59,049 bars you get x =1 extra bars for recycling y = 3 wrappers but each bar has z = 1 wrappers so Az/Dy = 59,049z/3 = +19683 those 19683 will give you an extra 6561 which gives you an exta 2187 which gives you an extra 729 which gives you an extra 243 which gives you an extra 81 which gives you an extra 27 which gives you an extra 9 which gives you an extra 3 which gives you an extra 1
final answer 88573
THE ans is not 88573 ....... the ans is 78732. ......cuz the general eq.....i have found is ---> n + n%3 (i.e reminder of n/3) + n/3 here take only the integer part of the quotient....and here "n" is $n so, the concept here is for e.g if A is giving 7 dollars.....he gets 7 bars....now he gives 6 wrappers to get 2 bars.....so for now totally he has 9.....now he again give 3 wrapper to get 1 so,,totally he gets 10 chocolates....this follows the same for 59,049.......AND THE FORMULA WORKS CHEERS
If B gives $4, he will get 4 chocolates and 4 wrappers. He then give 3 wrappers and get 1 chocolate, which means he gets 1 more wrapper, so 5 chocolates with 2 wrappers, right?
Now let n = 4 : 4 + 4 % 3 + 4 / 3 = 4 + 1 + 1 3 1 = 6 3 1
So according to your formula, B should get 6 and 1/3 chocolates. Clearly something is wrong with your formula.
As long as you hold one wrapper, you can treat the wrapper recycling as "pay two dollars for three chocolates". This is because you can use the wrapper you have, plus two more wrappers you just got from the two dollars, to obtain another chocolate (and another wrapper). Thus, with $ 5 9 , 0 4 9 , we buy one to obtain one wrapper ( 1 chocolate), then exchange the remaining $ 5 9 , 0 4 8 to give 2 3 ⋅ 5 9 0 4 8 = 8 8 5 7 2 chocolates. In total, you obtain 8 8 5 7 3 chocolates, plus one wrapper left.
Note that we need the one wrapper condition. If we only think of "pay two dollars for three chocolates", we will erroneously conclude that $ 2 gives 3 chocolates while it only gives 2 (but if we can borrow one wrapper, it indeed gives 3 chocolates and we can return the wrapper immediately).
59049+(Sum 59049/3^n from 1 to 59049)
I wrote an equation for this and the only way that I could express it on this comment thread was for me to post it on my website, the answer is 88,573 candy bars. This problem can be solved with a convergent summation of 59,049/(3^n) from n=0 to n=10. There is literally nothing else but the equation on my website. http://seniorsonnet14analysis.com/
I wish there was a way for me to post images in the comments so that I wouldn't have to post it on my website.
Can be simply put as.. For n dollars .. You can buy n choc...then from n wrappers n/3 choc....then n/9 choc from n/3 wrappers and so on....thus total choc u can buy is infinite summation of GP with first term n and common ratio 1/3 ... By logical deduction the exact formula is (3n-1)/2
This is a summation series with formula (1/(3^n)) where n starts from zero to any value you want.
Could you please explain how to apply the formula in context of this problem?
Problem Loading...
Note Loading...
Set Loading...
Here is how to get the maximum number of chocolates:
So, you can get a maximum of 8 8 5 7 3 chocolates.
General solution: For $n, you get n + ⌊ 2 n − 1 ⌋ chocolates.
Vote this solution up if you liked it, thanks.