2
$\begingroup$

I am working on a write-up and want to say that a variable is a positive integer (including zero). Would this be said as "variable is in the set of all nonnegative integers"? Maybe there is a different notation I should be using? In the event that I do want to use set notation, how would I write it in symbols?

$\endgroup$
1
  • 1
    $\begingroup$ I'd just say "the variable is a non-negative integer". (Note: $0$ is not a positive number. Positive means strictly greater than $0$) There's no point is specifically saying "variable is in the set of all nonnegative integers" as every object is an element of the set that describes it. It's enough to just say "variable is non-negative integer". If you wont notation $x\in \{n\in \mathbb Z| n \ge 0\}$ is fine but there is also the notation $\mathbb Z^+$ which conventionally (and maybe confusedly) includes $0$. There's also $\mathbb N \cup \{0\}$. $\endgroup$
    – fleablood
    Nov 28, 2022 at 1:40

2 Answers 2

2
$\begingroup$

Saying that a variable is a nonnegative integer does include $0$. Sometimes people define the set of natural numbers $\mathbb{N}$ so that $0 \in \mathbb{N}$, though it is usually explicitly stated.

In set builder notation, you could denote the set of nonnegative integers with $$\{x\in\mathbb{Z} \mid x \ge0\}$$

$\endgroup$
2
$\begingroup$

You could say $x\in\mathbb{N}$ or $x\in\mathbb{Z^+}$. $\mathbb{N}$ is the set of natural numbers and $\mathbb{Z^+}$ is the set of positive integers, which are essentially the same thing.

$\endgroup$
3
  • 1
    $\begingroup$ Another common notation is $\mathbb{Z}^{\geq 0}$, which solves the ambiguity in both $\mathbb{N}$ and $\mathbb{Z}^+$ of whether you take them to mean “positive” or “strictly positive”. $\endgroup$ Nov 28, 2022 at 10:25
  • 2
    $\begingroup$ The OP said he wants to include 0. He doesn’t just want positive integers. $\endgroup$
    – bubba
    Nov 28, 2022 at 10:29
  • $\begingroup$ @PeterLeFanuLumsdaine never saw that one before. The more you know. $\endgroup$ Nov 28, 2022 at 15:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .