represents the domain of non-negative integers, as in x∈NonNegativeIntegers.
NonNegativeIntegers
represents the domain of non-negative integers, as in x∈NonNegativeIntegers.
Details
- x∈NonNegativeIntegers evaluates immediately if x is a numeric quantity.
- Simplify[expr∈NonNegativeIntegers,assum] can be used to try to determine whether an expression is a non-negative integer under the given assumptions.
- (x1|x2|…)∈NonNegativeIntegers and {x1,x2,…}∈NonNegativeIntegers test whether all xi are non-negative integers.
- NonNegativeIntegers is output in StandardForm or TraditionalForm as
. This typeset form can be input using
nnints
.
Examples
open all close allBasic Examples (3)
Seven is a non-negative integer:
Element[7, NonNegativeIntegers]If
is an integer,
is a non-negative integer:
Simplify[EulerPhi[n]^2∈NonNegativeIntegers, n∈ℤ]Find non-negative integer solutions of a Pell equation:
Reduce[x ^ 2 - 2y ^ 2 == 1, {x, y}, NonNegativeIntegers]Scope (6)
Test domain membership of a numeric expression:
1234567∈NonNegativeIntegersMake domain membership assumptions:
Refine[Sin[n Pi] ≤ n, n∈NonNegativeIntegers]FullSimplify[x ^ n + y ^ n == z ^ n, (x | y | z | n)∈NonNegativeIntegers && n > 3 && x y z ≠ 0]Specify the default domain over which a function should work:
Reduce[(x ^ 999997 - 25x ^ 12345 + 24x)(x - 7)(x ^ 2 - 9) == 0, x, NonNegativeIntegers]FindInstance[x ^ 2 + y ^ 2 + z ^ 2 + t ^ 2 + u ^ 2 + v ^ 2 + w ^ 2 == 1234567890987654321, {x, y, z, t, u, v, w}, NonNegativeIntegers]Solve an optimization problem over the non-negative integers:
Minimize[{x ^ 2 + x y}, {x, y}, NonNegativeIntegers]Test whether several numbers are non-negative integers:
(x | y | 1)∈NonNegativeIntegersIf any number is explicitly not a non-negative integer, the result is False:
{x, y, -1}∈NonNegativeIntegersTraditionalForm formatting:
NonNegativeIntegers//TraditionalFormApplications (1)
Testing membership in the non-negative integers is a fast way to verify non-negativity of a large list:
list = RandomInteger[{0, 100}, 1000000];AbsoluteTiming[list∈NonNegativeIntegers]AbsoluteTiming[MatchQ[list, {__Integer ? NonNegative}]]Properties & Relations (3)
Membership in NonNegativeIntegers is equivalent to membership in Integers and non-negativity:
x∈NonNegativeIntegersNonNegativeIntegers is contained in NonNegativeReals and NonNegativeRationals:
Refine[x∈NonNegativeReals, x∈NonNegativeIntegers]Refine[x∈NonNegativeRationals, x∈NonNegativeIntegers]NonNegativeIntegers is disjoint from NegativeIntegers:
Reduce[x∈NegativeIntegers, x, NonNegativeIntegers]It intersects NonPositiveIntegers:
Reduce[x∈NonPositiveIntegers, x, NonNegativeIntegers]Related Guides
History
Text
Wolfram Research (2019), NonNegativeIntegers, Wolfram Language function, https://reference.wolfram.com/language/ref/NonNegativeIntegers.html.
CMS
Wolfram Language. 2019. "NonNegativeIntegers." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/NonNegativeIntegers.html.
APA
Wolfram Language. (2019). NonNegativeIntegers. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NonNegativeIntegers.html
BibTeX
@misc{reference.wolfram_2026_nonnegativeintegers, author="Wolfram Research", title="{NonNegativeIntegers}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/NonNegativeIntegers.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_nonnegativeintegers, organization={Wolfram Research}, title={NonNegativeIntegers}, year={2019}, url={https://reference.wolfram.com/language/ref/NonNegativeIntegers.html}, note=[Accessed: 12-June-2026]}