Arrange $n$ tiles in a rectangle pattern












3














Is there a way to find how to arrange $n$ tiles in order to form a rectangle that is closest to a square? As I result I am looking for the dimension of that rectangle if it exists.



For example, here are the results I expect from $1$ to $9$.




  1. a 1 by 1 square, fairly simple.

  2. a 1 by 2 rectangle.

  3. a 1 by 3 rectangle.

  4. a 2 by 2 square.

  5. this is impossible because a 1 by 5 rectangle is thinner than the previous shape.

  6. a 2 by 3 rectangle.

  7. this is impossible.

  8. a 2 by 4 rectangle.

  9. a 3 by 3 square.


I am only looking at $n$ smaller than $100$ but would rather not have to hardcode everything.










share|cite|improve this question









New contributor




Alex Laquerre is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    3














    Is there a way to find how to arrange $n$ tiles in order to form a rectangle that is closest to a square? As I result I am looking for the dimension of that rectangle if it exists.



    For example, here are the results I expect from $1$ to $9$.




    1. a 1 by 1 square, fairly simple.

    2. a 1 by 2 rectangle.

    3. a 1 by 3 rectangle.

    4. a 2 by 2 square.

    5. this is impossible because a 1 by 5 rectangle is thinner than the previous shape.

    6. a 2 by 3 rectangle.

    7. this is impossible.

    8. a 2 by 4 rectangle.

    9. a 3 by 3 square.


    I am only looking at $n$ smaller than $100$ but would rather not have to hardcode everything.










    share|cite|improve this question









    New contributor




    Alex Laquerre is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      3












      3








      3







      Is there a way to find how to arrange $n$ tiles in order to form a rectangle that is closest to a square? As I result I am looking for the dimension of that rectangle if it exists.



      For example, here are the results I expect from $1$ to $9$.




      1. a 1 by 1 square, fairly simple.

      2. a 1 by 2 rectangle.

      3. a 1 by 3 rectangle.

      4. a 2 by 2 square.

      5. this is impossible because a 1 by 5 rectangle is thinner than the previous shape.

      6. a 2 by 3 rectangle.

      7. this is impossible.

      8. a 2 by 4 rectangle.

      9. a 3 by 3 square.


      I am only looking at $n$ smaller than $100$ but would rather not have to hardcode everything.










      share|cite|improve this question









      New contributor




      Alex Laquerre is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      Is there a way to find how to arrange $n$ tiles in order to form a rectangle that is closest to a square? As I result I am looking for the dimension of that rectangle if it exists.



      For example, here are the results I expect from $1$ to $9$.




      1. a 1 by 1 square, fairly simple.

      2. a 1 by 2 rectangle.

      3. a 1 by 3 rectangle.

      4. a 2 by 2 square.

      5. this is impossible because a 1 by 5 rectangle is thinner than the previous shape.

      6. a 2 by 3 rectangle.

      7. this is impossible.

      8. a 2 by 4 rectangle.

      9. a 3 by 3 square.


      I am only looking at $n$ smaller than $100$ but would rather not have to hardcode everything.







      geometry square-numbers rectangles






      share|cite|improve this question









      New contributor




      Alex Laquerre is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|cite|improve this question









      New contributor




      Alex Laquerre is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|cite|improve this question




      share|cite|improve this question








      edited 2 days ago









      dmtri

      1,4201521




      1,4201521






      New contributor




      Alex Laquerre is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked Dec 31 '18 at 2:18









      Alex Laquerre

      161




      161




      New contributor




      Alex Laquerre is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Alex Laquerre is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Alex Laquerre is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          1 Answer
          1






          active

          oldest

          votes


















          5














          Although your problem statement doesn't explicitly state it, your examples indicate that you want the value of the lower of the $2$ factors to never decrease. Thus, each increase of the lower factor among your examples occurs at a square, such as $1$ being $1 text{ by } 1$, $4$ being $2 text{ by } 2$ and $9$ being $3 text{ by } 3$.



          If this is a correct assumption on my part, and there are no other unstated conditions, then each next value which is not "impossible" would be the integers which are multiples of the current "low" factor until you encounter the square of the next higher integer. Thus, continuing from what you have written, the next valid values would be $12 = 3 times 4$ and $15 = 3 times 5$ for a lower value of $3$ before you hit the next square at $16 = 4 times 4$. From there, the next values would be $20 = 4 times 5$ and $24 = 4 times 6$ before you encounter $25 = 5 times 5$. You can then continue like this until you reach $100$ or most any other limit you care to set.



          To check for any specific value representing a valid rectangle, including what its shape would be, or if it's impossible, you need to determine what the largest perfect square is less or than or equal to your number. This can be done by using the integer part of the square root. For example, the square root of $143$ is $11.9ldots$ so the factor to check is $11$. As $143 = 11 times 13$, it is a valid rectangle. However, $142$ down to $133$ will not work, with $132 = 11 times 12$ being the next smaller value which would work.



          As previously written by Ross Millikan in the comments below, stated more succinctly using mathematical terminology, for any positive integer $n$, determine $k = lfloor sqrt{n} rfloor$. If $k$ divides $n$, then the rectangle is $k times frac{n}{k}$, else it's impossible.






          share|cite|improve this answer























          • No, you're completely right. However, how could, given n of let's say 94, I know what's the shape without calculating every number by hand?
            – Alex Laquerre
            2 days ago






          • 2




            Just determine the smallest perfect square less than or equal to the value. For $94$, that is $81 = 9 times 9$. Next, check if $9$ is a factor of $94$. It isn't in this case, so $94$ would be considered "impossible" by your algorithm. I hope this makes sense.
            – John Omielan
            2 days ago








          • 1




            What I gather from John's answer is that, given $n$, you find $d$, the integer part of the square root of $n$, and then you check whether $d$ divides $n$. If it does, then $d$ by $n/d$ is what you want. If it doesn't, then that $n$ doesn't work.
            – Gerry Myerson
            2 days ago






          • 1




            Stated as an algorithm, given $n$ compute $k=lfloor sqrt n rfloor$. If $k$ divides $n$ the rectangle is $k times frac nk$. If $k$ does not divide $n$ it is impossible. Good answer.
            – Ross Millikan
            2 days ago








          • 1




            You are welcome to edit it into your answer, which will make it more accessible to readers.
            – Ross Millikan
            2 days ago











          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
          });


          }
          });






          Alex Laquerre is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3057384%2farrange-n-tiles-in-a-rectangle-pattern%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









          5














          Although your problem statement doesn't explicitly state it, your examples indicate that you want the value of the lower of the $2$ factors to never decrease. Thus, each increase of the lower factor among your examples occurs at a square, such as $1$ being $1 text{ by } 1$, $4$ being $2 text{ by } 2$ and $9$ being $3 text{ by } 3$.



          If this is a correct assumption on my part, and there are no other unstated conditions, then each next value which is not "impossible" would be the integers which are multiples of the current "low" factor until you encounter the square of the next higher integer. Thus, continuing from what you have written, the next valid values would be $12 = 3 times 4$ and $15 = 3 times 5$ for a lower value of $3$ before you hit the next square at $16 = 4 times 4$. From there, the next values would be $20 = 4 times 5$ and $24 = 4 times 6$ before you encounter $25 = 5 times 5$. You can then continue like this until you reach $100$ or most any other limit you care to set.



          To check for any specific value representing a valid rectangle, including what its shape would be, or if it's impossible, you need to determine what the largest perfect square is less or than or equal to your number. This can be done by using the integer part of the square root. For example, the square root of $143$ is $11.9ldots$ so the factor to check is $11$. As $143 = 11 times 13$, it is a valid rectangle. However, $142$ down to $133$ will not work, with $132 = 11 times 12$ being the next smaller value which would work.



          As previously written by Ross Millikan in the comments below, stated more succinctly using mathematical terminology, for any positive integer $n$, determine $k = lfloor sqrt{n} rfloor$. If $k$ divides $n$, then the rectangle is $k times frac{n}{k}$, else it's impossible.






          share|cite|improve this answer























          • No, you're completely right. However, how could, given n of let's say 94, I know what's the shape without calculating every number by hand?
            – Alex Laquerre
            2 days ago






          • 2




            Just determine the smallest perfect square less than or equal to the value. For $94$, that is $81 = 9 times 9$. Next, check if $9$ is a factor of $94$. It isn't in this case, so $94$ would be considered "impossible" by your algorithm. I hope this makes sense.
            – John Omielan
            2 days ago








          • 1




            What I gather from John's answer is that, given $n$, you find $d$, the integer part of the square root of $n$, and then you check whether $d$ divides $n$. If it does, then $d$ by $n/d$ is what you want. If it doesn't, then that $n$ doesn't work.
            – Gerry Myerson
            2 days ago






          • 1




            Stated as an algorithm, given $n$ compute $k=lfloor sqrt n rfloor$. If $k$ divides $n$ the rectangle is $k times frac nk$. If $k$ does not divide $n$ it is impossible. Good answer.
            – Ross Millikan
            2 days ago








          • 1




            You are welcome to edit it into your answer, which will make it more accessible to readers.
            – Ross Millikan
            2 days ago
















          5














          Although your problem statement doesn't explicitly state it, your examples indicate that you want the value of the lower of the $2$ factors to never decrease. Thus, each increase of the lower factor among your examples occurs at a square, such as $1$ being $1 text{ by } 1$, $4$ being $2 text{ by } 2$ and $9$ being $3 text{ by } 3$.



          If this is a correct assumption on my part, and there are no other unstated conditions, then each next value which is not "impossible" would be the integers which are multiples of the current "low" factor until you encounter the square of the next higher integer. Thus, continuing from what you have written, the next valid values would be $12 = 3 times 4$ and $15 = 3 times 5$ for a lower value of $3$ before you hit the next square at $16 = 4 times 4$. From there, the next values would be $20 = 4 times 5$ and $24 = 4 times 6$ before you encounter $25 = 5 times 5$. You can then continue like this until you reach $100$ or most any other limit you care to set.



          To check for any specific value representing a valid rectangle, including what its shape would be, or if it's impossible, you need to determine what the largest perfect square is less or than or equal to your number. This can be done by using the integer part of the square root. For example, the square root of $143$ is $11.9ldots$ so the factor to check is $11$. As $143 = 11 times 13$, it is a valid rectangle. However, $142$ down to $133$ will not work, with $132 = 11 times 12$ being the next smaller value which would work.



          As previously written by Ross Millikan in the comments below, stated more succinctly using mathematical terminology, for any positive integer $n$, determine $k = lfloor sqrt{n} rfloor$. If $k$ divides $n$, then the rectangle is $k times frac{n}{k}$, else it's impossible.






          share|cite|improve this answer























          • No, you're completely right. However, how could, given n of let's say 94, I know what's the shape without calculating every number by hand?
            – Alex Laquerre
            2 days ago






          • 2




            Just determine the smallest perfect square less than or equal to the value. For $94$, that is $81 = 9 times 9$. Next, check if $9$ is a factor of $94$. It isn't in this case, so $94$ would be considered "impossible" by your algorithm. I hope this makes sense.
            – John Omielan
            2 days ago








          • 1




            What I gather from John's answer is that, given $n$, you find $d$, the integer part of the square root of $n$, and then you check whether $d$ divides $n$. If it does, then $d$ by $n/d$ is what you want. If it doesn't, then that $n$ doesn't work.
            – Gerry Myerson
            2 days ago






          • 1




            Stated as an algorithm, given $n$ compute $k=lfloor sqrt n rfloor$. If $k$ divides $n$ the rectangle is $k times frac nk$. If $k$ does not divide $n$ it is impossible. Good answer.
            – Ross Millikan
            2 days ago








          • 1




            You are welcome to edit it into your answer, which will make it more accessible to readers.
            – Ross Millikan
            2 days ago














          5












          5








          5






          Although your problem statement doesn't explicitly state it, your examples indicate that you want the value of the lower of the $2$ factors to never decrease. Thus, each increase of the lower factor among your examples occurs at a square, such as $1$ being $1 text{ by } 1$, $4$ being $2 text{ by } 2$ and $9$ being $3 text{ by } 3$.



          If this is a correct assumption on my part, and there are no other unstated conditions, then each next value which is not "impossible" would be the integers which are multiples of the current "low" factor until you encounter the square of the next higher integer. Thus, continuing from what you have written, the next valid values would be $12 = 3 times 4$ and $15 = 3 times 5$ for a lower value of $3$ before you hit the next square at $16 = 4 times 4$. From there, the next values would be $20 = 4 times 5$ and $24 = 4 times 6$ before you encounter $25 = 5 times 5$. You can then continue like this until you reach $100$ or most any other limit you care to set.



          To check for any specific value representing a valid rectangle, including what its shape would be, or if it's impossible, you need to determine what the largest perfect square is less or than or equal to your number. This can be done by using the integer part of the square root. For example, the square root of $143$ is $11.9ldots$ so the factor to check is $11$. As $143 = 11 times 13$, it is a valid rectangle. However, $142$ down to $133$ will not work, with $132 = 11 times 12$ being the next smaller value which would work.



          As previously written by Ross Millikan in the comments below, stated more succinctly using mathematical terminology, for any positive integer $n$, determine $k = lfloor sqrt{n} rfloor$. If $k$ divides $n$, then the rectangle is $k times frac{n}{k}$, else it's impossible.






          share|cite|improve this answer














          Although your problem statement doesn't explicitly state it, your examples indicate that you want the value of the lower of the $2$ factors to never decrease. Thus, each increase of the lower factor among your examples occurs at a square, such as $1$ being $1 text{ by } 1$, $4$ being $2 text{ by } 2$ and $9$ being $3 text{ by } 3$.



          If this is a correct assumption on my part, and there are no other unstated conditions, then each next value which is not "impossible" would be the integers which are multiples of the current "low" factor until you encounter the square of the next higher integer. Thus, continuing from what you have written, the next valid values would be $12 = 3 times 4$ and $15 = 3 times 5$ for a lower value of $3$ before you hit the next square at $16 = 4 times 4$. From there, the next values would be $20 = 4 times 5$ and $24 = 4 times 6$ before you encounter $25 = 5 times 5$. You can then continue like this until you reach $100$ or most any other limit you care to set.



          To check for any specific value representing a valid rectangle, including what its shape would be, or if it's impossible, you need to determine what the largest perfect square is less or than or equal to your number. This can be done by using the integer part of the square root. For example, the square root of $143$ is $11.9ldots$ so the factor to check is $11$. As $143 = 11 times 13$, it is a valid rectangle. However, $142$ down to $133$ will not work, with $132 = 11 times 12$ being the next smaller value which would work.



          As previously written by Ross Millikan in the comments below, stated more succinctly using mathematical terminology, for any positive integer $n$, determine $k = lfloor sqrt{n} rfloor$. If $k$ divides $n$, then the rectangle is $k times frac{n}{k}$, else it's impossible.







          share|cite|improve this answer














          share|cite|improve this answer



          share|cite|improve this answer








          edited 2 days ago

























          answered 2 days ago









          John Omielan

          99418




          99418












          • No, you're completely right. However, how could, given n of let's say 94, I know what's the shape without calculating every number by hand?
            – Alex Laquerre
            2 days ago






          • 2




            Just determine the smallest perfect square less than or equal to the value. For $94$, that is $81 = 9 times 9$. Next, check if $9$ is a factor of $94$. It isn't in this case, so $94$ would be considered "impossible" by your algorithm. I hope this makes sense.
            – John Omielan
            2 days ago








          • 1




            What I gather from John's answer is that, given $n$, you find $d$, the integer part of the square root of $n$, and then you check whether $d$ divides $n$. If it does, then $d$ by $n/d$ is what you want. If it doesn't, then that $n$ doesn't work.
            – Gerry Myerson
            2 days ago






          • 1




            Stated as an algorithm, given $n$ compute $k=lfloor sqrt n rfloor$. If $k$ divides $n$ the rectangle is $k times frac nk$. If $k$ does not divide $n$ it is impossible. Good answer.
            – Ross Millikan
            2 days ago








          • 1




            You are welcome to edit it into your answer, which will make it more accessible to readers.
            – Ross Millikan
            2 days ago


















          • No, you're completely right. However, how could, given n of let's say 94, I know what's the shape without calculating every number by hand?
            – Alex Laquerre
            2 days ago






          • 2




            Just determine the smallest perfect square less than or equal to the value. For $94$, that is $81 = 9 times 9$. Next, check if $9$ is a factor of $94$. It isn't in this case, so $94$ would be considered "impossible" by your algorithm. I hope this makes sense.
            – John Omielan
            2 days ago








          • 1




            What I gather from John's answer is that, given $n$, you find $d$, the integer part of the square root of $n$, and then you check whether $d$ divides $n$. If it does, then $d$ by $n/d$ is what you want. If it doesn't, then that $n$ doesn't work.
            – Gerry Myerson
            2 days ago






          • 1




            Stated as an algorithm, given $n$ compute $k=lfloor sqrt n rfloor$. If $k$ divides $n$ the rectangle is $k times frac nk$. If $k$ does not divide $n$ it is impossible. Good answer.
            – Ross Millikan
            2 days ago








          • 1




            You are welcome to edit it into your answer, which will make it more accessible to readers.
            – Ross Millikan
            2 days ago
















          No, you're completely right. However, how could, given n of let's say 94, I know what's the shape without calculating every number by hand?
          – Alex Laquerre
          2 days ago




          No, you're completely right. However, how could, given n of let's say 94, I know what's the shape without calculating every number by hand?
          – Alex Laquerre
          2 days ago




          2




          2




          Just determine the smallest perfect square less than or equal to the value. For $94$, that is $81 = 9 times 9$. Next, check if $9$ is a factor of $94$. It isn't in this case, so $94$ would be considered "impossible" by your algorithm. I hope this makes sense.
          – John Omielan
          2 days ago






          Just determine the smallest perfect square less than or equal to the value. For $94$, that is $81 = 9 times 9$. Next, check if $9$ is a factor of $94$. It isn't in this case, so $94$ would be considered "impossible" by your algorithm. I hope this makes sense.
          – John Omielan
          2 days ago






          1




          1




          What I gather from John's answer is that, given $n$, you find $d$, the integer part of the square root of $n$, and then you check whether $d$ divides $n$. If it does, then $d$ by $n/d$ is what you want. If it doesn't, then that $n$ doesn't work.
          – Gerry Myerson
          2 days ago




          What I gather from John's answer is that, given $n$, you find $d$, the integer part of the square root of $n$, and then you check whether $d$ divides $n$. If it does, then $d$ by $n/d$ is what you want. If it doesn't, then that $n$ doesn't work.
          – Gerry Myerson
          2 days ago




          1




          1




          Stated as an algorithm, given $n$ compute $k=lfloor sqrt n rfloor$. If $k$ divides $n$ the rectangle is $k times frac nk$. If $k$ does not divide $n$ it is impossible. Good answer.
          – Ross Millikan
          2 days ago






          Stated as an algorithm, given $n$ compute $k=lfloor sqrt n rfloor$. If $k$ divides $n$ the rectangle is $k times frac nk$. If $k$ does not divide $n$ it is impossible. Good answer.
          – Ross Millikan
          2 days ago






          1




          1




          You are welcome to edit it into your answer, which will make it more accessible to readers.
          – Ross Millikan
          2 days ago




          You are welcome to edit it into your answer, which will make it more accessible to readers.
          – Ross Millikan
          2 days ago










          Alex Laquerre is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          Alex Laquerre is a new contributor. Be nice, and check out our Code of Conduct.













          Alex Laquerre is a new contributor. Be nice, and check out our Code of Conduct.












          Alex Laquerre is a new contributor. Be nice, and check out our Code of Conduct.
















          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.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • 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.


          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%2f3057384%2farrange-n-tiles-in-a-rectangle-pattern%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

          "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

          Alcedinidae

          RAC Tourist Trophy