If you see this, something is wrong
First published on Saturday, Mar 7, 2026 and last modified on Saturday, Mar 7, 2026
Compare Natural Integers
Now we shall compare natural integers with the comparison operators strictly less, strictly greater, less or equal and greater or equal.
How to compare two natural integers? Let's start with an example.
2 is less than 5.
This is because 2 is different from 5 And there is a chain of followers from 2 to 5.
And as illustrated, this is also equivalent to, on the natural integers line, 2 is to the left of 5.
So let's define the operator strictly less than between two distinct natural integers.
Let's consider two natural integers a and b.
Then the following equivalents holds: a is strictly less than d if and only if a is different from b and a is to the left of b on the line n of natural integers.
And now we shall structure the set N of natural integers with the comparison.
The set N is an increasing sequence.
0 is less than 1, that is less than 2, etc.
This is by construction of the natural integers line from left to right.
The smallest element is 0, it is the minimum.
This is because the line begins with 0, that is not a follower of any natural integer.
And it has no greatest element, no maximum, it is an unbounded set, because there is no end to the construction of the natural integer's line.
Now let's see other operators to compare two natural integers.
Let a and b be any two natural integers, distinct or equal.
Then a is greater than b strictly if and only if b is less than a strictly.
For instance, 5 is greater than 2 because 2 is less than 5.
a is less or equal than b if and only if either a is less than b strictly or a is equal to b.
For instance, 2 is less or equal to 5, because 2 is less than 5 strictly.
But also 2 is less or equal to 2 because 2 is equal to 2.
a is greater or equal to b if and only if either a is strictly greater than b, or a is equal to b.
For instance, 5 is greater or equal to 2 because 5 is greater to 2 strictly, but also 2 is greater or equal to 2 because 2 equals 2.
But what if we want to compare regular numbers in 10 basis? We can compare them digit by digit.
First we order the digits from 0 to 9 in an increasing order.
0 is less than 1, that is less than 2, etc.
until 9.
Then we compare the number of digits of the two numbers.
And then we compare the numbers with the same number of digits, digit by digit, from left to right.
But let's see in practice.
For two different numbers in 10 basis that are natural integers, we compare the number of digits and the greatest is the number with the biggest number of digits.
For instance, 132 that has three digits is less than 1064 that has four digits.
If they have the same number of digits, we compare the first left digits.
For instance, 356 is greater than 217 because 3 is bigger than 2.
If the first left digits are equal, we compare the next digits to the right.
For instance, 314 is less than 321, because 1 is less than 2, and 3 is equal to 3.
And we iterate until we find different digits.
For instance, 427 is greater than 425 because the 4s are the same, the 2s are the same, and 7 is greater than 5.
But let's see this in practice in Python.
Let's first compare zero to one.
Is zero strictly less than one? Yes, it is true.
0 < 1And one, is it strictly less than two? Yes, it is true.
1 < 2We continue.
Two, is it strictly less than three? Yes, it is true.
2 < 3Now we shall see the arrangement zero, strictly less than one, strictly less than two, strictly less than three.
And this is true.
0 < 1 < 2 < 3So we shall now compare all the digits from 0 to 9, with signs strictly less between all of them.
And this is true.
They are in the right order.
0 < 1 < 2 < 3 < 4 < 5 < 6 < 7 < 8 < 9But let's try to compare 3 with itself.
Is 3 strictly less than 3? No, this is false.
3 < 3But is 3 less or equal than three? Yes, this is true because three is equal to three.
3 <= 3Is three strictly greater than three? No, but it is greater or equal than three.
This is because 3 is equal to 3, 3 equal equal 3.
3 > 33 >= 33 == 3Is 3 not equal to 3? No this is false.
3 != 3Is 2 not equal to 3? This is true, because 2 is not 3.
2 != 3Is 3 not equal to 2? The reverse order.
Yes.
3 != 2Is 3 less than 2? No.
3 < 2Is 3 greater than 2? Yes.
3 > 2We have compared 2 and 3.
And this is a recapitulative table of comparison operators.
Strictly less, that is the same in mathematics as in Python.
less or equal, that is a little different in Python.
strictly greater, that is the same.
greater or equal, that is a little different.
equal, that is doubled in Python.
different, that is with exclamation point in Python.
What's coming now? We shall see the totally ordered set N, with less or equal.
We shall arrange the integers in increasing order formally.
Table of Comparison Operators