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?
prime-numbers divisibility prime-factorization
add a comment |
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?
prime-numbers divisibility prime-factorization
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
add a comment |
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?
prime-numbers divisibility prime-factorization
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
prime-numbers divisibility prime-factorization
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
add a comment |
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
add a comment |
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.
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Nov 19 at 0:32
Patrick Stevens
28.1k52874
28.1k52874
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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