Checking if the Product of n Integers is Divisible by Prime N











up vote
1
down vote

favorite












Given $n$ integers, $x_1, ... , x_n$, is there some well-known procedure or algorithm that checks if the product $x_1 * ... * x_n$ is divisible by some arbitrary prime $N$ using minimal space?



Since the product and $N$ can be arbitrarily large, I don't think you can just simply use modular arithmetic to see if the remainder is $0$. I was thinking maybe convert the product to its prime factorization, and if $N$ isn't one of the primes used, then we know the product cannot be divisible by $N$, right? Does this seem like something that could work?










share|cite|improve this question


















  • 2




    You don't need to do the multiplication, you can just check to see if $p$ divides any of $x_1,cdots, x_n$. Factoring is almost certainly a bad idea...that's very costly and unnecessary.
    – lulu
    Nov 19 at 0:28








  • 1




    Just trial divide each $x_i$ by $p$. Then $N$ is divisible by $p$ if and only at least one $x_i$ is.
    – Hagen von Eitzen
    Nov 19 at 0:28










  • What about writing down the prime decomposition of $x_i$ first, hence deriving the prime decomposition of $x_1x_2dotsm x_n$? Then proceed as you have written.
    – YiFan
    Nov 19 at 0:29















up vote
1
down vote

favorite












Given $n$ integers, $x_1, ... , x_n$, is there some well-known procedure or algorithm that checks if the product $x_1 * ... * x_n$ is divisible by some arbitrary prime $N$ using minimal space?



Since the product and $N$ can be arbitrarily large, I don't think you can just simply use modular arithmetic to see if the remainder is $0$. I was thinking maybe convert the product to its prime factorization, and if $N$ isn't one of the primes used, then we know the product cannot be divisible by $N$, right? Does this seem like something that could work?










share|cite|improve this question


















  • 2




    You don't need to do the multiplication, you can just check to see if $p$ divides any of $x_1,cdots, x_n$. Factoring is almost certainly a bad idea...that's very costly and unnecessary.
    – lulu
    Nov 19 at 0:28








  • 1




    Just trial divide each $x_i$ by $p$. Then $N$ is divisible by $p$ if and only at least one $x_i$ is.
    – Hagen von Eitzen
    Nov 19 at 0:28










  • What about writing down the prime decomposition of $x_i$ first, hence deriving the prime decomposition of $x_1x_2dotsm x_n$? Then proceed as you have written.
    – YiFan
    Nov 19 at 0:29













up vote
1
down vote

favorite









up vote
1
down vote

favorite











Given $n$ integers, $x_1, ... , x_n$, is there some well-known procedure or algorithm that checks if the product $x_1 * ... * x_n$ is divisible by some arbitrary prime $N$ using minimal space?



Since the product and $N$ can be arbitrarily large, I don't think you can just simply use modular arithmetic to see if the remainder is $0$. I was thinking maybe convert the product to its prime factorization, and if $N$ isn't one of the primes used, then we know the product cannot be divisible by $N$, right? Does this seem like something that could work?










share|cite|improve this question













Given $n$ integers, $x_1, ... , x_n$, is there some well-known procedure or algorithm that checks if the product $x_1 * ... * x_n$ is divisible by some arbitrary prime $N$ using minimal space?



Since the product and $N$ can be arbitrarily large, I don't think you can just simply use modular arithmetic to see if the remainder is $0$. I was thinking maybe convert the product to its prime factorization, and if $N$ isn't one of the primes used, then we know the product cannot be divisible by $N$, right? Does this seem like something that could work?







prime-numbers divisibility prime-factorization






share|cite|improve this question













share|cite|improve this question











share|cite|improve this question




share|cite|improve this question










asked Nov 19 at 0:26









Axioms

755




755








  • 2




    You don't need to do the multiplication, you can just check to see if $p$ divides any of $x_1,cdots, x_n$. Factoring is almost certainly a bad idea...that's very costly and unnecessary.
    – lulu
    Nov 19 at 0:28








  • 1




    Just trial divide each $x_i$ by $p$. Then $N$ is divisible by $p$ if and only at least one $x_i$ is.
    – Hagen von Eitzen
    Nov 19 at 0:28










  • What about writing down the prime decomposition of $x_i$ first, hence deriving the prime decomposition of $x_1x_2dotsm x_n$? Then proceed as you have written.
    – YiFan
    Nov 19 at 0:29














  • 2




    You don't need to do the multiplication, you can just check to see if $p$ divides any of $x_1,cdots, x_n$. Factoring is almost certainly a bad idea...that's very costly and unnecessary.
    – lulu
    Nov 19 at 0:28








  • 1




    Just trial divide each $x_i$ by $p$. Then $N$ is divisible by $p$ if and only at least one $x_i$ is.
    – Hagen von Eitzen
    Nov 19 at 0:28










  • What about writing down the prime decomposition of $x_i$ first, hence deriving the prime decomposition of $x_1x_2dotsm x_n$? Then proceed as you have written.
    – YiFan
    Nov 19 at 0:29








2




2




You don't need to do the multiplication, you can just check to see if $p$ divides any of $x_1,cdots, x_n$. Factoring is almost certainly a bad idea...that's very costly and unnecessary.
– lulu
Nov 19 at 0:28






You don't need to do the multiplication, you can just check to see if $p$ divides any of $x_1,cdots, x_n$. Factoring is almost certainly a bad idea...that's very costly and unnecessary.
– lulu
Nov 19 at 0:28






1




1




Just trial divide each $x_i$ by $p$. Then $N$ is divisible by $p$ if and only at least one $x_i$ is.
– Hagen von Eitzen
Nov 19 at 0:28




Just trial divide each $x_i$ by $p$. Then $N$ is divisible by $p$ if and only at least one $x_i$ is.
– Hagen von Eitzen
Nov 19 at 0:28












What about writing down the prime decomposition of $x_i$ first, hence deriving the prime decomposition of $x_1x_2dotsm x_n$? Then proceed as you have written.
– YiFan
Nov 19 at 0:29




What about writing down the prime decomposition of $x_i$ first, hence deriving the prime decomposition of $x_1x_2dotsm x_n$? Then proceed as you have written.
– YiFan
Nov 19 at 0:29










1 Answer
1






active

oldest

votes

















up vote
3
down vote













Note that primes are prime: that is, if $p mid a b$ then $p mid a$ or $p mid b$. (This is Euclid's lemma.) Inductively, then, if $p mid x_1 x_2 dots x_n$ then $p$ divides some $x_i$. So just check each of the $x_i$ in turn. Modular arithmetic is fine for that.






share|cite|improve this answer





















    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',
    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%2f3004331%2fchecking-if-the-product-of-n-integers-is-divisible-by-prime-n%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








    up vote
    3
    down vote













    Note that primes are prime: that is, if $p mid a b$ then $p mid a$ or $p mid b$. (This is Euclid's lemma.) Inductively, then, if $p mid x_1 x_2 dots x_n$ then $p$ divides some $x_i$. So just check each of the $x_i$ in turn. Modular arithmetic is fine for that.






    share|cite|improve this answer

























      up vote
      3
      down vote













      Note that primes are prime: that is, if $p mid a b$ then $p mid a$ or $p mid b$. (This is Euclid's lemma.) Inductively, then, if $p mid x_1 x_2 dots x_n$ then $p$ divides some $x_i$. So just check each of the $x_i$ in turn. Modular arithmetic is fine for that.






      share|cite|improve this answer























        up vote
        3
        down vote










        up vote
        3
        down vote









        Note that primes are prime: that is, if $p mid a b$ then $p mid a$ or $p mid b$. (This is Euclid's lemma.) Inductively, then, if $p mid x_1 x_2 dots x_n$ then $p$ divides some $x_i$. So just check each of the $x_i$ in turn. Modular arithmetic is fine for that.






        share|cite|improve this answer












        Note that primes are prime: that is, if $p mid a b$ then $p mid a$ or $p mid b$. (This is Euclid's lemma.) Inductively, then, if $p mid x_1 x_2 dots x_n$ then $p$ divides some $x_i$. So just check each of the $x_i$ in turn. Modular arithmetic is fine for that.







        share|cite|improve this answer












        share|cite|improve this answer



        share|cite|improve this answer










        answered Nov 19 at 0:32









        Patrick Stevens

        28.2k52874




        28.2k52874






























            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.





            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%2f3004331%2fchecking-if-the-product-of-n-integers-is-divisible-by-prime-n%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

            mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

            How to change which sound is reproduced for terminal bell?

            Can I use Tabulator js library in my java Spring + Thymeleaf project?