AQA 7517, section 4.5.1.1
A natural number is a whole number that is zero or positive. The set of natural numbers is written :
In AQA's specification, the natural numbers include zero. (Some textbooks start at 1, so always use the course definition.)
Key properties
- They are whole numbers with no fractional part.
- They are never negative.
- The set is infinite: there is always a bigger one, but it is countable, because you can list them in order 0, 1, 2, 3...
- Adding or multiplying two natural numbers always gives another natural number. Subtracting might not: is not a natural number.
Where they are used in computing
- Counting how many items there are: the length of a list, the number of students.
- Array indexes and loop counters: 0, 1, 2, ...
- Unsigned binary numbers, which can only represent natural numbers (see 4.5.4.1).
- Memory addresses and the size of files.
items = ["a", "b", "c"]
print(len(items)) # 3: a natural number
for i in range(len(items)):
print(i) # 0, 1, 2: also natural numbers
Worked example
Task: which of these are natural numbers: 0, 7, -3, 2.5, 100?
- 0: yes, because zero is included.
- 7: yes.
- -3: no, because it is negative.
- 2.5: no, because it has a fractional part.
- 100: yes.
Exam tip: state that includes zero and has no negative or fractional numbers. In programming, the data type for this is often an unsigned integer.
Check yourself
Does the set of natural numbers include zero?
Yes, in this specification .
Give two uses of natural numbers in a program
Any two of: counting items; array indexes; loop counters; sizes and lengths; memory addresses.
Is the result of 4 − 9 a natural number?
No. It is −5, which is negative.