This is a more challenging version of the reported puzzle " How will you get 100 fruits in Rs. 100? "

Bob buys 4 different fruits for exactly 100 dollars

Jackfruits cost 15 dollars each

Papayas cost 1 dollar each

Bananas cost 0.29 dollars each

Strawberries cost 0.13 dollars each

There are 100 fruits in total

The number of each fruit he buys is a Prime Number. So he buys at least 2 of each fruit. All the numbers are different

So how many Jackfruits, papayas, bananas and strawberries did he buy?

Please explain the logic.

No Programming please


2 Answers 2


As instructed by Great Teacher Gareth, let's put the fruit on sale, and lower each price by a dollar:

  • Jackfruits, now only 14 dollars each!
  • Papayas FOR FREE!
  • Get 71 cents with every free Banana!
  • Take our Strawberries, and we'll give you 87 cents!

and then we'll try to

spend exactly zero dollars. We instantly notice how this makes the number of papayas irrelevant, so we'll just have to figure out the rest, and then "fill up to 100" with papayas.

We'll want to figure out a

prime numbered combination of strawberries and bananas that ends up at either -28, -42, or -70 dollars, because those are the possible costs of jackfruit that we need to offset.

Let's use trial and error, which is now easy, since we have a definite target:

Start with the largest prime number of bananas that fits inside the target price, and 2 strawberries. If the sum is too high, lower the number of bananas, and if it's too low, add strawberries, always skipping any non-prime values. This process makes quick work of the checking process, while making sure you won't miss any solutions. (I used a calculator for this, which may be against the spirit of the no-computers tag, though.)

By doing so, we get that

* We cannot get to -28 at all
* We cannot get to -42 at all
* The only way to get to -70 is to get 41 bananas and 47 strawberries

That seems nice, and the numbers are smaller than a 100, so all that remains to be done is to check the number of papayas for primality.

Adding up the other numbers, we know that there must be 7 papayas.

Yay, it IS prime, and it's different from the other numbers, so we have a solution!

* 5 Jackfruits
* 7 Papayas
* 41 Bananas
* 47 Strawberries

  • $\begingroup$ Adds to 102 @ Bass Typo perhaps? $\endgroup$
    – DrD
    Commented Nov 6, 2018 at 13:35


47 strawberries
41 bananas
7 papayas
5 jackfruits

How to solve it:

First, convert everything to cents, so we can work with integers. So a strawberry cost 13 cents, a banana 29, a papaya 100 and a jackfruit 1500. We would like to buy 100 fruits in total, which cost 10000 cents altogether. The number of strawberries bought determines the number of bananas to be bought, as their total cost has to be divisible by 100, as the other kind of fruits each have a cost divisible by hundred, and so does our total budget. To determine this connection between the number of strawberries and bananas, we have to find the multiplicative inverse of 29 (price of bananas) modulo 100. This happens to be 69, as 29*69=2001. Given this, if the number of strawberries is x, the number of bananas has to be (x*13*(100-69) mod 100), that is (3*x mod 100). Indeed it is easy to check that 1*13+3*29=100, and you can find this without looking for modular multiplicative inverses.
There have to be more than 33 strawberries (for the multiplication by three to force a carry in the hundreds), otherwise the number of bananas cannot be prime. If we also consider the criteria about the total number of fruits being 100, that gives new boundaries for the number of strawberries: it either has to be between 34 and 50 (the carry is 1 in these cases) or between 67 and 75 (the carry is 2).

As it happens,

none of the primes in interval [67,75] work, as for 67, we get 1 banana (not prime), and for 71 and 73 the budget left for papayas and jackfruits is 8700 and 8500, which makes the number of papayas to be a compound number divisible by 3 or 5 respectively.
The primes in the interval [34,50] all give primes for the needed number of bananas as well. Trying to use the least amount of papayas to have a budget which is divisible by 1500 (price of jackfruit) leaves us with 47 as the only solution, as for all the other cases the difference of 100 (target number of fruits) and the actual number of bought fruits is not divisible by 14, which is a necessary condition to be fulfilled - as 1 jackfruit could be replaced by 15 papayas for the same price, increasing the total number of fruits by 14.

  • $\begingroup$ Was it still trial and error or some logic? $\endgroup$
    – DrD
    Commented Nov 6, 2018 at 12:54
  • $\begingroup$ @DEEM Is there an existing logical solution? $\endgroup$
    – rhsquared
    Commented Nov 6, 2018 at 13:19
  • 1
    $\begingroup$ Of course this answer is right. But when I came up with the puzzle, I started with "elimination" logic. For example Jackfruits cannot be >5 so only 2,3 and 5. Cannot be 2 because 3 prime numbers will not add to 98. $\endgroup$
    – DrD
    Commented Nov 6, 2018 at 13:34
  • $\begingroup$ @DEEM, it would be interesting to see your approach being applied to solve the problem. I'd personally like to see a solution not using any kind of trial an error. Could you maybe share your method as an answer? $\endgroup$
    – elias
    Commented Nov 7, 2018 at 9:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.