Artificial intelligent assistant

Calculating number of paid and free products for an x+y offer I'm working on a `x+y` offer feature for a cart system and trying to figure out a way to split a quantity added by the user into paid and free products based on the offer. Here's the rundown: products in stock: 16 offer: 2 + 1 (every 2 items in cart gets 1 free) ### Example 1 items added to cart: 16 paid items: 11 free items: 5 ### Example 2 items added to cart: 14 paid items: 10 free items: 4 ### Example 3 items added to cart: 13 paid items: 9 free items: 4 ### Example 3 items added to cart: 11 paid: 8 free: 3 Is there a way to determine these two values through a simple formula?

You could simply round up the fraction of paid items, and round down the number of free items. If $n = x + y$ is the total number of items, we find:

$$x = \left \lceil \frac{2}{3}n \right \rceil, y = \left \lfloor \frac{1}{3}n \right \rfloor$$

As an example, for $n = 16$ we find:

$$x = \left \lceil 10.\overline{6} \right \rceil = 11, y = \left \lfloor 5.\overline{3} \right \rfloor = 5$$

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 04000bb9c1d368a1c6c3256aad3a2f00