Find all possible multiplicand who results in given number












0












$begingroup$


I have some random figure let's say 400, I need equation to find all possible combinations (of integer) whose multiplication will results in 400. Condition is number of factors (multiplicand) will be dynamic.



For example, for 400 with two factors I need output as



1 * 400
2 * 200
4 * 100
5 * 80
etc...


means all a and b where a * b = 400.



Same with 3 factors,



1 * 1 * 400
1 * 2 * 200
2 * 2 * 100
etc...


mean all a, b, and c where a * b * c = 400. We can do this by iterating loop for each possibility, but this approach takes longer time. I need solution that can give answer in minimum possible time. Thanks.










share|cite|improve this question









$endgroup$

















    0












    $begingroup$


    I have some random figure let's say 400, I need equation to find all possible combinations (of integer) whose multiplication will results in 400. Condition is number of factors (multiplicand) will be dynamic.



    For example, for 400 with two factors I need output as



    1 * 400
    2 * 200
    4 * 100
    5 * 80
    etc...


    means all a and b where a * b = 400.



    Same with 3 factors,



    1 * 1 * 400
    1 * 2 * 200
    2 * 2 * 100
    etc...


    mean all a, b, and c where a * b * c = 400. We can do this by iterating loop for each possibility, but this approach takes longer time. I need solution that can give answer in minimum possible time. Thanks.










    share|cite|improve this question









    $endgroup$















      0












      0








      0





      $begingroup$


      I have some random figure let's say 400, I need equation to find all possible combinations (of integer) whose multiplication will results in 400. Condition is number of factors (multiplicand) will be dynamic.



      For example, for 400 with two factors I need output as



      1 * 400
      2 * 200
      4 * 100
      5 * 80
      etc...


      means all a and b where a * b = 400.



      Same with 3 factors,



      1 * 1 * 400
      1 * 2 * 200
      2 * 2 * 100
      etc...


      mean all a, b, and c where a * b * c = 400. We can do this by iterating loop for each possibility, but this approach takes longer time. I need solution that can give answer in minimum possible time. Thanks.










      share|cite|improve this question









      $endgroup$




      I have some random figure let's say 400, I need equation to find all possible combinations (of integer) whose multiplication will results in 400. Condition is number of factors (multiplicand) will be dynamic.



      For example, for 400 with two factors I need output as



      1 * 400
      2 * 200
      4 * 100
      5 * 80
      etc...


      means all a and b where a * b = 400.



      Same with 3 factors,



      1 * 1 * 400
      1 * 2 * 200
      2 * 2 * 100
      etc...


      mean all a, b, and c where a * b * c = 400. We can do this by iterating loop for each possibility, but this approach takes longer time. I need solution that can give answer in minimum possible time. Thanks.







      products






      share|cite|improve this question













      share|cite|improve this question











      share|cite|improve this question




      share|cite|improve this question










      asked Jul 3 '14 at 13:09









      RaviRavi

      101




      101






















          1 Answer
          1






          active

          oldest

          votes


















          0












          $begingroup$

          It looks like you're looking only at positive integers, so we'll stick with that. Also, you're looking for an algorithm more than you're looking for an equation.



          First, find the prime factorization of the number. Let's say it's composed of the product of $N$ prime factors (which may be repeated, of course).



          All of the terms in any of your products will need to be these factors, or products of these factors, or $1$, or the number itself.



          To find all of the possible products with $M$ terms, you'll need to find all of the possible products with $1, 2, dots, min(M,N)$ terms, but for each case, you'll only need to find them once. (The function $min(N,M)$ means the minimum of $M$ and $N$.) Here's why.



          You show three cases for three-term solutions for the product of $400$: $$1 times 1 times 400 = 400, \ 1 times 2 times 200 = 400, \ 2 times 2 times 100 = 400.$$



          The first one is really a trivial extension of a one-term answer: $400.$ It's just padded with $1$'s.



          The second one is really a trivial extension of a two-term answer: $2 times 200.$ It's just padded with a $1$.



          The third one is a non-trivial three-term answer.



          So the set of all possible products with $M$ terms ($M leq N$) is the set of non-trivial products with $M$ terms, plus all of the trivial ones created by padding products of $1, 2, dots, M-1$ terms with the appropriate number of $1$'s.



          If $M > N$, then there are no non-trivial products left, so you'll simply pad all of the products (trivial and non-trivial) with $M-N$ $1$'s, and those will be the products in addition to the ones you found for $M leq N$.






          share|cite|improve this answer









          $endgroup$













            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%2f855347%2ffind-all-possible-multiplicand-who-results-in-given-number%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









            0












            $begingroup$

            It looks like you're looking only at positive integers, so we'll stick with that. Also, you're looking for an algorithm more than you're looking for an equation.



            First, find the prime factorization of the number. Let's say it's composed of the product of $N$ prime factors (which may be repeated, of course).



            All of the terms in any of your products will need to be these factors, or products of these factors, or $1$, or the number itself.



            To find all of the possible products with $M$ terms, you'll need to find all of the possible products with $1, 2, dots, min(M,N)$ terms, but for each case, you'll only need to find them once. (The function $min(N,M)$ means the minimum of $M$ and $N$.) Here's why.



            You show three cases for three-term solutions for the product of $400$: $$1 times 1 times 400 = 400, \ 1 times 2 times 200 = 400, \ 2 times 2 times 100 = 400.$$



            The first one is really a trivial extension of a one-term answer: $400.$ It's just padded with $1$'s.



            The second one is really a trivial extension of a two-term answer: $2 times 200.$ It's just padded with a $1$.



            The third one is a non-trivial three-term answer.



            So the set of all possible products with $M$ terms ($M leq N$) is the set of non-trivial products with $M$ terms, plus all of the trivial ones created by padding products of $1, 2, dots, M-1$ terms with the appropriate number of $1$'s.



            If $M > N$, then there are no non-trivial products left, so you'll simply pad all of the products (trivial and non-trivial) with $M-N$ $1$'s, and those will be the products in addition to the ones you found for $M leq N$.






            share|cite|improve this answer









            $endgroup$


















              0












              $begingroup$

              It looks like you're looking only at positive integers, so we'll stick with that. Also, you're looking for an algorithm more than you're looking for an equation.



              First, find the prime factorization of the number. Let's say it's composed of the product of $N$ prime factors (which may be repeated, of course).



              All of the terms in any of your products will need to be these factors, or products of these factors, or $1$, or the number itself.



              To find all of the possible products with $M$ terms, you'll need to find all of the possible products with $1, 2, dots, min(M,N)$ terms, but for each case, you'll only need to find them once. (The function $min(N,M)$ means the minimum of $M$ and $N$.) Here's why.



              You show three cases for three-term solutions for the product of $400$: $$1 times 1 times 400 = 400, \ 1 times 2 times 200 = 400, \ 2 times 2 times 100 = 400.$$



              The first one is really a trivial extension of a one-term answer: $400.$ It's just padded with $1$'s.



              The second one is really a trivial extension of a two-term answer: $2 times 200.$ It's just padded with a $1$.



              The third one is a non-trivial three-term answer.



              So the set of all possible products with $M$ terms ($M leq N$) is the set of non-trivial products with $M$ terms, plus all of the trivial ones created by padding products of $1, 2, dots, M-1$ terms with the appropriate number of $1$'s.



              If $M > N$, then there are no non-trivial products left, so you'll simply pad all of the products (trivial and non-trivial) with $M-N$ $1$'s, and those will be the products in addition to the ones you found for $M leq N$.






              share|cite|improve this answer









              $endgroup$
















                0












                0








                0





                $begingroup$

                It looks like you're looking only at positive integers, so we'll stick with that. Also, you're looking for an algorithm more than you're looking for an equation.



                First, find the prime factorization of the number. Let's say it's composed of the product of $N$ prime factors (which may be repeated, of course).



                All of the terms in any of your products will need to be these factors, or products of these factors, or $1$, or the number itself.



                To find all of the possible products with $M$ terms, you'll need to find all of the possible products with $1, 2, dots, min(M,N)$ terms, but for each case, you'll only need to find them once. (The function $min(N,M)$ means the minimum of $M$ and $N$.) Here's why.



                You show three cases for three-term solutions for the product of $400$: $$1 times 1 times 400 = 400, \ 1 times 2 times 200 = 400, \ 2 times 2 times 100 = 400.$$



                The first one is really a trivial extension of a one-term answer: $400.$ It's just padded with $1$'s.



                The second one is really a trivial extension of a two-term answer: $2 times 200.$ It's just padded with a $1$.



                The third one is a non-trivial three-term answer.



                So the set of all possible products with $M$ terms ($M leq N$) is the set of non-trivial products with $M$ terms, plus all of the trivial ones created by padding products of $1, 2, dots, M-1$ terms with the appropriate number of $1$'s.



                If $M > N$, then there are no non-trivial products left, so you'll simply pad all of the products (trivial and non-trivial) with $M-N$ $1$'s, and those will be the products in addition to the ones you found for $M leq N$.






                share|cite|improve this answer









                $endgroup$



                It looks like you're looking only at positive integers, so we'll stick with that. Also, you're looking for an algorithm more than you're looking for an equation.



                First, find the prime factorization of the number. Let's say it's composed of the product of $N$ prime factors (which may be repeated, of course).



                All of the terms in any of your products will need to be these factors, or products of these factors, or $1$, or the number itself.



                To find all of the possible products with $M$ terms, you'll need to find all of the possible products with $1, 2, dots, min(M,N)$ terms, but for each case, you'll only need to find them once. (The function $min(N,M)$ means the minimum of $M$ and $N$.) Here's why.



                You show three cases for three-term solutions for the product of $400$: $$1 times 1 times 400 = 400, \ 1 times 2 times 200 = 400, \ 2 times 2 times 100 = 400.$$



                The first one is really a trivial extension of a one-term answer: $400.$ It's just padded with $1$'s.



                The second one is really a trivial extension of a two-term answer: $2 times 200.$ It's just padded with a $1$.



                The third one is a non-trivial three-term answer.



                So the set of all possible products with $M$ terms ($M leq N$) is the set of non-trivial products with $M$ terms, plus all of the trivial ones created by padding products of $1, 2, dots, M-1$ terms with the appropriate number of $1$'s.



                If $M > N$, then there are no non-trivial products left, so you'll simply pad all of the products (trivial and non-trivial) with $M-N$ $1$'s, and those will be the products in addition to the ones you found for $M leq N$.







                share|cite|improve this answer












                share|cite|improve this answer



                share|cite|improve this answer










                answered Jul 3 '14 at 14:17









                JohnJohn

                22.6k32450




                22.6k32450






























                    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%2f855347%2ffind-all-possible-multiplicand-who-results-in-given-number%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

                    Ellipse (mathématiques)

                    Quarter-circle Tiles

                    Mont Emei