Positive Integers

class sage.sets.positive_integers.PositiveIntegers

Bases: sage.sets.integer_range.IntegerRangeInfinite

The enumerated set of positive integers. To fix the ideas, we mean \(\{1, 2, 3, 4, 5, \dots \}\).

This class implements the set of positive integers, as an enumerated set (see InfiniteEnumeratedSets).

This set is an integer range set. The construction is therefore done by IntegerRange (see IntegerRange).

EXAMPLES:

sage: PP = PositiveIntegers()
sage: PP
Positive integers
sage: PP.cardinality()
+Infinity
sage: TestSuite(PP).run()
sage: PP.list()
Traceback (most recent call last):
...
NotImplementedError: infinite list
sage: it = iter(PP)
sage: (it.next(), it.next(), it.next(), it.next(), it.next())
(1, 2, 3, 4, 5)
sage: PP.first()
1

TESTS:

sage: TestSuite(PositiveIntegers()).run()
an_element()

Returns an element of self.

EXAMPLES:

sage: PositiveIntegers().an_element()
42

Previous topic

Integer Range

Next topic

Non Negative Integers

This Page