Apply “buy X get Y” discount on N products












1












$begingroup$


Consider a product is added to a cart with quantity of N and "Buy X and get y" offer is applied i.e. Buy two get one free.



If n = 3 then I could simply apply a discount rate of 33.33 on each product.
But my problem occurs when there are more than 3.



If n = 4 then number of free products would still be 1 and I would have to pay full price for 4th product, but if I apply the above method I would be applying discount on the 4th product as well which should not be the case.



This continues for n = 4,5,6,7,8,9,.....



I need a formula to correctly calculate the price with the scheme applied.



Thank you.



Edit: Edited the question as it was not clear. Sorry.



X would be the number of products that needs to be purchased for the offer to apply and N would be the number of products that are actually in the cart.










share|cite|improve this question











$endgroup$

















    1












    $begingroup$


    Consider a product is added to a cart with quantity of N and "Buy X and get y" offer is applied i.e. Buy two get one free.



    If n = 3 then I could simply apply a discount rate of 33.33 on each product.
    But my problem occurs when there are more than 3.



    If n = 4 then number of free products would still be 1 and I would have to pay full price for 4th product, but if I apply the above method I would be applying discount on the 4th product as well which should not be the case.



    This continues for n = 4,5,6,7,8,9,.....



    I need a formula to correctly calculate the price with the scheme applied.



    Thank you.



    Edit: Edited the question as it was not clear. Sorry.



    X would be the number of products that needs to be purchased for the offer to apply and N would be the number of products that are actually in the cart.










    share|cite|improve this question











    $endgroup$















      1












      1








      1





      $begingroup$


      Consider a product is added to a cart with quantity of N and "Buy X and get y" offer is applied i.e. Buy two get one free.



      If n = 3 then I could simply apply a discount rate of 33.33 on each product.
      But my problem occurs when there are more than 3.



      If n = 4 then number of free products would still be 1 and I would have to pay full price for 4th product, but if I apply the above method I would be applying discount on the 4th product as well which should not be the case.



      This continues for n = 4,5,6,7,8,9,.....



      I need a formula to correctly calculate the price with the scheme applied.



      Thank you.



      Edit: Edited the question as it was not clear. Sorry.



      X would be the number of products that needs to be purchased for the offer to apply and N would be the number of products that are actually in the cart.










      share|cite|improve this question











      $endgroup$




      Consider a product is added to a cart with quantity of N and "Buy X and get y" offer is applied i.e. Buy two get one free.



      If n = 3 then I could simply apply a discount rate of 33.33 on each product.
      But my problem occurs when there are more than 3.



      If n = 4 then number of free products would still be 1 and I would have to pay full price for 4th product, but if I apply the above method I would be applying discount on the 4th product as well which should not be the case.



      This continues for n = 4,5,6,7,8,9,.....



      I need a formula to correctly calculate the price with the scheme applied.



      Thank you.



      Edit: Edited the question as it was not clear. Sorry.



      X would be the number of products that needs to be purchased for the offer to apply and N would be the number of products that are actually in the cart.







      algebra-precalculus percentages






      share|cite|improve this question















      share|cite|improve this question













      share|cite|improve this question




      share|cite|improve this question








      edited Dec 24 '18 at 7:04







      sdb1995

















      asked Dec 24 '18 at 6:41









      sdb1995sdb1995

      113




      113






















          1 Answer
          1






          active

          oldest

          votes


















          2












          $begingroup$

          The simple answer is if one orders $n$ of the product you get $lfloor frac n3 rfloor$ free and pay for $n-lfloor frac n3 rfloor$






          share|cite|improve this answer









          $endgroup$













          • $begingroup$
            I don't think that will work. The discount must be on an integral number of widgets. There would only be one free widget for four purchased. Please see the example in the question, then see my answer.
            $endgroup$
            – Adam Hrankowski
            Dec 24 '18 at 6:52






          • 1




            $begingroup$
            That is exactly the point of the floor function. You round the fraction down to the next whole number. It is exactly what you asked for-the last of three is free.
            $endgroup$
            – Ross Millikan
            Dec 24 '18 at 6:58










          • $begingroup$
            Oh, you are right. I read your answer too quickly and didn't catch the notation. I'll delete my answer as it is therefore a duplicate.
            $endgroup$
            – Adam Hrankowski
            Dec 24 '18 at 7:01










          • $begingroup$
            Thanks a lot. It worked. I've edited my question to clarify X and N.
            $endgroup$
            – sdb1995
            Dec 24 '18 at 7:04










          • $begingroup$
            So the general formula would be if N >= X then we can pay for n - floor(n/x)
            $endgroup$
            – sdb1995
            Dec 24 '18 at 7:10











          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
          });
          });
          }, "mathjax-editing");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "69"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          noCode: true, onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3051000%2fapply-buy-x-get-y-discount-on-n-products%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2












          $begingroup$

          The simple answer is if one orders $n$ of the product you get $lfloor frac n3 rfloor$ free and pay for $n-lfloor frac n3 rfloor$






          share|cite|improve this answer









          $endgroup$













          • $begingroup$
            I don't think that will work. The discount must be on an integral number of widgets. There would only be one free widget for four purchased. Please see the example in the question, then see my answer.
            $endgroup$
            – Adam Hrankowski
            Dec 24 '18 at 6:52






          • 1




            $begingroup$
            That is exactly the point of the floor function. You round the fraction down to the next whole number. It is exactly what you asked for-the last of three is free.
            $endgroup$
            – Ross Millikan
            Dec 24 '18 at 6:58










          • $begingroup$
            Oh, you are right. I read your answer too quickly and didn't catch the notation. I'll delete my answer as it is therefore a duplicate.
            $endgroup$
            – Adam Hrankowski
            Dec 24 '18 at 7:01










          • $begingroup$
            Thanks a lot. It worked. I've edited my question to clarify X and N.
            $endgroup$
            – sdb1995
            Dec 24 '18 at 7:04










          • $begingroup$
            So the general formula would be if N >= X then we can pay for n - floor(n/x)
            $endgroup$
            – sdb1995
            Dec 24 '18 at 7:10
















          2












          $begingroup$

          The simple answer is if one orders $n$ of the product you get $lfloor frac n3 rfloor$ free and pay for $n-lfloor frac n3 rfloor$






          share|cite|improve this answer









          $endgroup$













          • $begingroup$
            I don't think that will work. The discount must be on an integral number of widgets. There would only be one free widget for four purchased. Please see the example in the question, then see my answer.
            $endgroup$
            – Adam Hrankowski
            Dec 24 '18 at 6:52






          • 1




            $begingroup$
            That is exactly the point of the floor function. You round the fraction down to the next whole number. It is exactly what you asked for-the last of three is free.
            $endgroup$
            – Ross Millikan
            Dec 24 '18 at 6:58










          • $begingroup$
            Oh, you are right. I read your answer too quickly and didn't catch the notation. I'll delete my answer as it is therefore a duplicate.
            $endgroup$
            – Adam Hrankowski
            Dec 24 '18 at 7:01










          • $begingroup$
            Thanks a lot. It worked. I've edited my question to clarify X and N.
            $endgroup$
            – sdb1995
            Dec 24 '18 at 7:04










          • $begingroup$
            So the general formula would be if N >= X then we can pay for n - floor(n/x)
            $endgroup$
            – sdb1995
            Dec 24 '18 at 7:10














          2












          2








          2





          $begingroup$

          The simple answer is if one orders $n$ of the product you get $lfloor frac n3 rfloor$ free and pay for $n-lfloor frac n3 rfloor$






          share|cite|improve this answer









          $endgroup$



          The simple answer is if one orders $n$ of the product you get $lfloor frac n3 rfloor$ free and pay for $n-lfloor frac n3 rfloor$







          share|cite|improve this answer












          share|cite|improve this answer



          share|cite|improve this answer










          answered Dec 24 '18 at 6:46









          Ross MillikanRoss Millikan

          299k24200374




          299k24200374












          • $begingroup$
            I don't think that will work. The discount must be on an integral number of widgets. There would only be one free widget for four purchased. Please see the example in the question, then see my answer.
            $endgroup$
            – Adam Hrankowski
            Dec 24 '18 at 6:52






          • 1




            $begingroup$
            That is exactly the point of the floor function. You round the fraction down to the next whole number. It is exactly what you asked for-the last of three is free.
            $endgroup$
            – Ross Millikan
            Dec 24 '18 at 6:58










          • $begingroup$
            Oh, you are right. I read your answer too quickly and didn't catch the notation. I'll delete my answer as it is therefore a duplicate.
            $endgroup$
            – Adam Hrankowski
            Dec 24 '18 at 7:01










          • $begingroup$
            Thanks a lot. It worked. I've edited my question to clarify X and N.
            $endgroup$
            – sdb1995
            Dec 24 '18 at 7:04










          • $begingroup$
            So the general formula would be if N >= X then we can pay for n - floor(n/x)
            $endgroup$
            – sdb1995
            Dec 24 '18 at 7:10


















          • $begingroup$
            I don't think that will work. The discount must be on an integral number of widgets. There would only be one free widget for four purchased. Please see the example in the question, then see my answer.
            $endgroup$
            – Adam Hrankowski
            Dec 24 '18 at 6:52






          • 1




            $begingroup$
            That is exactly the point of the floor function. You round the fraction down to the next whole number. It is exactly what you asked for-the last of three is free.
            $endgroup$
            – Ross Millikan
            Dec 24 '18 at 6:58










          • $begingroup$
            Oh, you are right. I read your answer too quickly and didn't catch the notation. I'll delete my answer as it is therefore a duplicate.
            $endgroup$
            – Adam Hrankowski
            Dec 24 '18 at 7:01










          • $begingroup$
            Thanks a lot. It worked. I've edited my question to clarify X and N.
            $endgroup$
            – sdb1995
            Dec 24 '18 at 7:04










          • $begingroup$
            So the general formula would be if N >= X then we can pay for n - floor(n/x)
            $endgroup$
            – sdb1995
            Dec 24 '18 at 7:10
















          $begingroup$
          I don't think that will work. The discount must be on an integral number of widgets. There would only be one free widget for four purchased. Please see the example in the question, then see my answer.
          $endgroup$
          – Adam Hrankowski
          Dec 24 '18 at 6:52




          $begingroup$
          I don't think that will work. The discount must be on an integral number of widgets. There would only be one free widget for four purchased. Please see the example in the question, then see my answer.
          $endgroup$
          – Adam Hrankowski
          Dec 24 '18 at 6:52




          1




          1




          $begingroup$
          That is exactly the point of the floor function. You round the fraction down to the next whole number. It is exactly what you asked for-the last of three is free.
          $endgroup$
          – Ross Millikan
          Dec 24 '18 at 6:58




          $begingroup$
          That is exactly the point of the floor function. You round the fraction down to the next whole number. It is exactly what you asked for-the last of three is free.
          $endgroup$
          – Ross Millikan
          Dec 24 '18 at 6:58












          $begingroup$
          Oh, you are right. I read your answer too quickly and didn't catch the notation. I'll delete my answer as it is therefore a duplicate.
          $endgroup$
          – Adam Hrankowski
          Dec 24 '18 at 7:01




          $begingroup$
          Oh, you are right. I read your answer too quickly and didn't catch the notation. I'll delete my answer as it is therefore a duplicate.
          $endgroup$
          – Adam Hrankowski
          Dec 24 '18 at 7:01












          $begingroup$
          Thanks a lot. It worked. I've edited my question to clarify X and N.
          $endgroup$
          – sdb1995
          Dec 24 '18 at 7:04




          $begingroup$
          Thanks a lot. It worked. I've edited my question to clarify X and N.
          $endgroup$
          – sdb1995
          Dec 24 '18 at 7:04












          $begingroup$
          So the general formula would be if N >= X then we can pay for n - floor(n/x)
          $endgroup$
          – sdb1995
          Dec 24 '18 at 7:10




          $begingroup$
          So the general formula would be if N >= X then we can pay for n - floor(n/x)
          $endgroup$
          – sdb1995
          Dec 24 '18 at 7:10


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Mathematics Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3051000%2fapply-buy-x-get-y-discount-on-n-products%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Wiesbaden

          Marschland

          Dieringhausen