For Calculating a Whole-Numbered Grocery Bill

This is a little piece I wrote in 2014.

Here’s the formula for calculating an even amount for your groceries at the supermarket.

Let ”T” be the total price of the order, ”P” be the price of a non-taxable item, ”G” be the price of a taxable item, ”t” be the tax on a taxable item (usually a percentage), ”n” is the number of non-taxable items in the order, and ”m” is the number of taxable items in the order. For the bill of your groceries to be an even amount, the following must be satisfied:

  T = $\displaystyle\sum\limits_{i=1}^n P_{n}$ + $\displaystyle\sum\limits_{i=1}^m G_{m}$ (1 + t)
All one needs to do is find an item Pn or Gm which makes ”T” a whole number. To put it in another way, you must satisfy this condition:

  $\displaystyle\sum\limits_{i=1}^m G_{m}=\frac{T - \sum\limits_{i=1}^n P_{n}}{(1 + t)}$
Where \displaystyle\sum\limits_{i=1}^m G_{m} equals a whole number.

So the next time someone at the checkout stand looks at their total and says, ”I can’t do that again even if I tried,” show them this article and explain to them that it can be done.

Jason Anderson

Jason Anderson has been hacking up computers for nearly 20 years and has been using Linux for over 15 years. Among that, he has a BBA in Accounting. Look him up on Twitter at @FakeJasonA and on Mastodon on @ertain@mast.linuxgamecast.com

Leave a Reply

Your email address will not be published. Required fields are marked *