<p>Fleshing out my comments into an answer: since divisibility is (trivially) reducible to division, and since division is (nontrivially) reducible to multiplication via approaches like Newton's method, then your problem should have the same time complexity as integer multiplication.  AFAIK, there are no known lower bounds for multiplication better than the trivial linear one, so the same should hold true of your problem - and in particular, since multiplication is known to have (essentially) $O(n\log n\log^* n)$ algorithms, your hopes for a $n\log n\log\log n$ lower bound are almost certainly in vain.</p>

<p>The reason that division reduces precisely in complexity to multiplication &mdash; as I understand it &mdash; is that Newton's method will do a sequence of multiplications of different escalating sizes; this means that if there's an algorithm for multiplication with complexity $\Theta(f(n))$ then the complexity of a division algorithm using this multiplication algorithm as an intermediate step will be along the lines of $\Theta\left(\sum_{k=0}^{\lg n} f(\frac{n}{2^k})\right)$ &mdash; and for all of the complexity classes under discussion this is just $\Theta(f(n))$.</p>

CC BY-SA 3.0
2016-07-06T20:20:22.243Z
Nitpick: I don't see how you get a lower bound from this kind of reasoning, even if we assume there are no better algorithms for multiplication than the best ones currently known.  Your reductions imply that divisibility is no harder than multiplication.  But there's still the possibility that divisibility might be easier than division and easier than multiplication, as divisibility only requires a yes/no answer instead of a number.  (At least, the reduction you mention doesn't seem to rule that out.)
D.W.
CC BY-SA 3.0
2016-07-06T21:20:04.067Z
@D.W. Agreed, and that's an excellent point; but I wasn't trying to get a lower bound. Rather, the point is that any lower bound on divisibility implies the corresponding lower bound on multiplication, and since no such bounds are known beyond the trivial linear bound, then getting any better-than-linear lower bound on divisibility (which is part of what OP asked for) is unlikely.
Steven Stadnicki
CC BY-SA 3.0
2016-07-06T21:21:37.527Z
@D.W. I wouldn't be wholly shocked to learn of a linear _upper_ bound on divisibility, and as you say that wouldn't specifically imply anything about upper bounds on multiplication, but there are no specific results in that direction AFAIK.
Steven Stadnicki
CC BY-SA 3.0
2013-07-26T00:49:49.670Z
2013-07-26T00:49:49.670Z
Steven Stadnicki
<p>I think there are Vedic type of hacks for some numbers ending in 3,7 etc. Or base 2^n divisors...</p>

<p>But generally speaking, the fastest division algorithm seems to be the norm.</p>

<p>The best one I know of without looking is Algorithm D of Knuth's Seminumerical methods... Never checked its correctness though. It runs in more or less O(mn-n^2) where m and n are the dividend and divisor... without factoring multiplication complexity... </p>

<p>A lower bound however could be surpringly low as your question is only concerned with the decision problem.</p>

CC BY-SA 3.0
2013-07-25T03:13:21.650Z
2013-07-25T03:28:17.237Z
2013-07-25T03:28:17.237Z
Phil
<p>What is the most efficient (in time complexity) algorithm known nowadays for the Divisibity Decision Problem: given two integers, say $a$ and $b$, does $a$ divide $b$? Let it be clear that what I ask for is not (necessarily) an algorithm for Remainder Calculation. I just want to know whether $a$ divides $b$ or not. Being more specific, my question is whether exists or not some recent algorithm for Divisibility with time complexity better than $O(m\log m\log\log m)$, where $m$ is the number of bits of $\max\{a,b\}$. Further, is $\Omega(m\log m\log\log m)$ the lower bound of this problem?</p>

<p>Thanks and regards, and sorry if this is such a naive question.</p>

CC BY-SA 3.0
2013-07-26T00:27:34.857Z
AFAIK there are no non-trivial lower bounds known.  I _believe_ multiplication and division are known to have essentially the same complexity (though it may possibly be up to a log log factor?) via Newton's method, and since there's no known nonlinear lower bound on multiplication then I think any lower bound of the form you're stating would be a major result.
Steven Stadnicki
CC BY-SA 3.0
2013-07-26T00:33:10.017Z
(Actually, looking at it now I think the log log factor goes away because while you're doing a nonconstant number of multiplications, they're not all of the same length, so the superlinear factors can be absorbed in the same way that, e.g., $\sum_{k=1}^{\lfloor\lg n\rfloor} \frac{n}{2^k}$ is still linear in $n$ even though it has a nonconstant number of 'linear' factors.)
Steven Stadnicki
<time-complexity><lower-bounds><nt.number-theory><primes>
What's the most efficient algorithm for Divisibility?
Leandro Zatesko
# What's the most efficient algorithm for Divisibility?

(Asked by: username_0 on 2013-03-07)

What is the most efficient (in time complexity) algorithm known nowadays for the Divisibity Decision Problem: given two integers, say $a$ and $b$, does $a$ divide $b$? Let it be clear that what I ask for is not (necessarily) an algorithm for Remainder Calculation. I just want to know whether $a$ divides $b$ or not. Being more specific, my question is whether exists or not some recent algorithm for Divisibility with time complexity better than $O(m\log m\log\log m)$, where $m$ is the number of bits of $\max\{a,b\}$. Further, is $\Omega(m\log m\log\log m)$ the lower bound of this problem?

Thanks and regards, and sorry if this is such a naive question.

**Tags:** time-complexity, lower-bounds, nt.number-theory, primes

> **Comments:**
> **username_1**: AFAIK there are no non-trivial lower bounds known.  I _believe_ multiplication and division are known to have essentially the same complexity (though it may possibly be up to a log log factor?) via Newton's method, and since there's no known nonlinear lower bound on multiplication then I think any lower bound of the form you're stating would be a major result.  
> **username_1**: (Actually, looking at it now I think the log log factor goes away because while you're doing a nonconstant number of multiplications, they're not all of the same length, so the superlinear factors can be absorbed in the same way that, e.g., $\sum_{k=1}^{\lfloor\lg n\rfloor} \frac{n}{2^k}$ is still linear in $n$ even though it has a nonconstant number of 'linear' factors.)  

---

## 2 answers

### Answer by username_1 on 2013-07-26. Score: 4

Fleshing out my comments into an answer: since divisibility is (trivially) reducible to division, and since division is (nontrivially) reducible to multiplication via approaches like Newton's method, then your problem should have the same time complexity as integer multiplication. AFAIK, there are no known lower bounds for multiplication better than the trivial linear one, so the same should hold true of your problem - and in particular, since multiplication is known to have (essentially) $O(n\log n\log^\* n)$ algorithms, your hopes for a $n\log n\log\log n$ lower bound are almost certainly in vain.

The reason that division reduces precisely in complexity to multiplication — as I understand it — is that Newton's method will do a sequence of multiplications of different escalating sizes; this means that if there's an algorithm for multiplication with complexity $\Theta(f(n))$ then the complexity of a division algorithm using this multiplication algorithm as an intermediate step will be along the lines of $\Theta\left(\sum\_{k=0}^{\lg n} f(\frac{n}{2^k})\right)$ — and for all of the complexity classes under discussion this is just $\Theta(f(n))$.

> **Comments:**
> **username_2**: Nitpick: I don't see how you get a lower bound from this kind of reasoning, even if we assume there are no better algorithms for multiplication than the best ones currently known.  Your reductions imply that divisibility is no harder than multiplication.  But there's still the possibility that divisibility might be easier than division and easier than multiplication, as divisibility only requires a yes/no answer instead of a number.  (At least, the reduction you mention doesn't seem to rule that out.)  
> **username_1**: @username_2 Agreed, and that's an excellent point; but I wasn't trying to get a lower bound. Rather, the point is that any lower bound on divisibility implies the corresponding lower bound on multiplication, and since no such bounds are known beyond the trivial linear bound, then getting any better-than-linear lower bound on divisibility (which is part of what OP asked for) is unlikely.  
> **username_1**: @username_2 I wouldn't be wholly shocked to learn of a linear _upper_ bound on divisibility, and as you say that wouldn't specifically imply anything about upper bounds on multiplication, but there are no specific results in that direction AFAIK.  

---

### Answer by username_3 on 2013-07-25. Score: -2

I think there are Vedic type of hacks for some numbers ending in 3,7 etc. Or base 2^n divisors...

But generally speaking, the fastest division algorithm seems to be the norm.

The best one I know of without looking is Algorithm D of Knuth's Seminumerical methods... Never checked its correctness though. It runs in more or less O(mn-n^2) where m and n are the dividend and divisor... without factoring multiplication complexity...

A lower bound however could be surpringly low as your question is only concerned with the decision problem.


---

