5
$\begingroup$

I know that there's resources out there but my professor told me that nothing is divisible by $0$ because you can't divide by $0$ which makes it a NaN

The class is related to programming we are defining a "divisible" function that takes two arguments and I have to return true or false, so that's the context. I tried to explain to him what the "Let $a,b∈\mathbb{Z}$. Then $a$ is divisible by $b$ if and only if there exists an integer $k$ such that $a=kb$" as one of the answerers said but the professor said that just because $a$ implies $b$ doesn't mean $b$ implies $a$.

Also, there is a strong hint that we are supposed to use a modulus standard built in function in the programming language and this mod function returns undefined if you ask it to do $0 \mod 0$ so there's also that.

$\endgroup$
  • 4
    $\begingroup$ How do you define "is divisible by"? $\endgroup$ – Xander Henderson Feb 20 '18 at 0:41
  • 2
    $\begingroup$ What exactly does "$a$ is divisble by $b$" mean? $\endgroup$ – Umberto P. Feb 20 '18 at 0:41
  • 3
    $\begingroup$ Whether or not $0$ divides $0$ in any particular mathematical context depends on how divisibility is defined there. Your reference to "NaN" suggests that you're interested in whether some computer language allows $0/0$. That depends on the language. $\endgroup$ – Ethan Bolker Feb 20 '18 at 0:44
  • 3
    $\begingroup$ I will point out that definitions here are not completely standardized. Under many definitions, $0$ is said to divide $0$ and $0$ is divisible by $0$. Under some other definitions however, $0$ is treated as a special case and is considered ineligible to receive such labels. It is, therefore, vitally important that you share with us the definition that you are being taught, and asking a question of this nature without that information only hurts your chances at being able to adequately and fully understand the problem and the answer your professor is giving you. $\endgroup$ – JMoravitz Feb 20 '18 at 1:09
  • 2
    $\begingroup$ "In what cases is $0$ not divisible by $0$?" For example when one takes as the primary definition of divisibility "$a$ is divisible by $b$ if and only if $\frac{a}{b}$ is an integer." This is as valid of a definition of divisibility as any other, however under this definition $0$ is divisible by every number except $0$ whereas in other more common definitions $0$ is in fact divisible by every number including zero. This alternate definition happens to agree with the more common definition in every case except when it comes to $0$ being divisible by $0$. $\endgroup$ – JMoravitz Feb 20 '18 at 1:52
8
$\begingroup$

Yes, it is. Formal definition of divisibility is the following:

Let $a,b \in \mathbb{Z}$. Then $a$ is divisible by $b$ if and only if there exists an integer $k$ such that $a = kb$.

Now, in your case, we have $a = b = 0$, that is, $0 = k\cdot0$ and there exists infinitely many such $k$ so yes, $0$ is divisible by $0$.

| cite | improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ You say "formal" but formal in regards to what? Is it as "formal" as, say, 1+1 = 2? $\endgroup$ – Smit Shah Feb 20 '18 at 1:23
  • $\begingroup$ I meant the definition used in mathematics, I generally take them as formal but I should have explained it in the beginning, you are right. $\endgroup$ – ArsenBerk Feb 20 '18 at 1:24
5
$\begingroup$

You should design your function to meet specifications.

Practical programming is not the same as pure math. It has different goals and different methods and different standards than the mathematical field does. Trying to argue with your professor about this means you're arguing specifications, not mathematical principles. As a developer, I applaud you for thinking of this edge case and asking about it. That's what a developer should do: clarify the specifications with the client. And in this case, it's something mathematicians do, too. As you see in the comments, they'll only talk about divisibility by 0 if you explain what mathematical framework (or equivalently, what axioms) you're working under. Context is everything in both fields.

Discussions about divisibility are usually motivated by needing to actually divide one thing by another. As a result, it's important to realize that a programming language or specification can define the arithmetic to be whatever is deemed useful. For integer arithmetic, $\frac{0}{0}$ and $0 \mod 0$ is usually defined to be an error. For floating point math, the languages I tested considered $\frac{0.0}{0.0}$ and $0.0 \mod 0.0$ to be either NaN or an error. In this mathematical framework, dividing by zero is meaningless, so it makes sense to say that divisibility by zero is false, even if we have to specifically define divisibility so that's the case.

Even in the normal arithmetic framework over the real numbers, though, dividing by zero is a weird edge case. In many contexts, it's simply considered an undefined quantity, particularly since it's not of interest to many of the fields you'll cover in your early education. (That's what they told you in high school algebra, right?) In these frameworks, we can make everything simpler and more intuitive by defining that nothing is divisible by zero. There may be exotic theories that give $\frac{0}{0}$ or $\frac{a}{0}$ some value, and in these frameworks, it might make sense to use a different definition of divisibility. But you're unlikely to encounter any situations in which these are useful if you're pursuing a career in software development (unless you're building software for mathematicians).


If you want to know why programming languages define their arithmetic this way, they do so because it's a useful definition for the vast majority of numerical calculations in software. Most software never intends to divide anything by zero, and trying to compute further results after encountering it will result in utter nonsense for a final answer. As a result, it's almost always better for your program to give an obviously nonsense response as early as possible, so you can discover you have a bug in your code, rather than wonder why you're getting $0$ in this one weird case where you assumptions failed you.


I do realize this is not really a mathematical answer. But I think it is the answer to the OP's question. If you feel this doesn't belong on this SE, I encourage you to close the question, perhaps with migration to another SE.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ Your answer is fine for the most part, but it seems to be missing the point of the question. The question does not directly ask about $\frac{0}{0}$, but rather it asks about whether $0$ is divisible by $0$. Although the result of $\frac{a}{b}$ is closely tied to whether or not $a$ is divisible by $b$ in the case of positive integers, the concepts are not the same when $0$ is involved and are separate enough to warrant a more careful answer that avoids unnecessarily talking about things that are only tangentially related but irrelevant to the actual question at hand. $\endgroup$ – JMoravitz Feb 20 '18 at 4:18
  • $\begingroup$ @JMoravitz Thanks, I'll try to clean it up in a little bit, although I think that the case of $\frac{0}{0}$ is pretty much what the professor was talking about. $\endgroup$ – jpmc26 Feb 20 '18 at 4:20
  • $\begingroup$ @JMoravitz Better? Or do you still see stuff I should cut out? $\endgroup$ – jpmc26 Feb 20 '18 at 4:57
-1
$\begingroup$

If you use algebra, the answer is zero. If A / B = C then C times B = A. For this example, A, B, and C are all zero.

To sum it up in a word problem: A birthday cake will be divided evenly among children at a party. The party got cancelled. There was no birthday cake and no children showed up. How big was the slice of cake each child got? Answer: Zero grams.

Another example: An electrical wire contains zero watts and zero volts. How many amps of electricity is in the wire? Amps = Watts / Volts. Answer: Zero amps.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ "If $A/B=C$ then $C\times B=A$", although a true statement, only makes sense when the expression on the left is valid. $A/B$ is not considered a valid expression in the case that $A$ and $B$ are both zero. But, that is a moot point since the question being asked is very explicitly "is $0$ divisible by $0$" which does not need any knowledge about nor need to make any reference to the expression $0/0$ and what it may or may not evaluate to or whether it is considered a valid expression. $\endgroup$ – JMoravitz Feb 22 '18 at 7:19
  • $\begingroup$ The way you have phrased your explanation makes one wonder whether you think the converse of your claim is true as well, that if $C\times B=A$ then $A/B=C$., which by setting $A=B=0$ and letting $C$ change would give you contradictions, seemingly implying that $0/0$ should equal every number at the same time. ($0=0\cdot 1=0\cdot 2=0\cdot 3=\dots$ dividing each by $0$ would seem to give you $\frac{0}{0}=1=2=3=\dots$) $\endgroup$ – JMoravitz Feb 22 '18 at 7:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.