To describe the World we need numbers and we start constructing the **natural numbers** 1, 2, 3, 4, and so on, as many as needed. We shall construct the natural numbers by the basic operation of +1 according a computer program of the form

- n = n + 1;

which starting with n = 0 as** zero** upon **repetition** constructs, 1 = 0 + 1, 2 = 1 + 1, 3 = 2 + 1, 4 = 3 +1, and so on. We shall see that the computer program n = n +1 is the mother of computer programs to construct-understand-control the world. Note that since 1 = 0 + 1 (or the same 1 = 1 + 0), it follows that 2 = 1 + 1 = 1 +1 + 0 = 2 + 0, and more generally n = n + 0 (or the same n = 0 + n), that is adding 0 is not adding anything at all.

Note that the number n on the left of = in the expression n = n +1, is a **new value** given as a **previous value on the right +1. **This means that the equality sign = is here used to express **assignment **in the sense that the number n on the left side is given (assigned) the new value n+1 with here n an old value. An equality sign can also express **identity, **which in code is denoted by == or === to make a distinction from = as assignment. An expression n == 2 can be true or false depending on the value given to n. An assignment = has no truth value; it is simply an assignment which cannot be false. There is much confusion concerning the meaning of = in traditional school mathematics. Connecting mathematics to code clears the picture, for both student and teacher.

We see that repetition of one and the same basic operation of +1 creates the rich output of the natural numbers. This is how the world is created piece by piece into something whole, like building a house brick by brick or a human cell by cell.

We thus understand that the operation +1 can mean many things, like eating another cake, taking another step, moving from grade 1 to grade 2, taking another breath, adding one dollar to your bank account, putting one more apple in a basket, you name it.

We here use the 2 as a shorthand of 1+1, 3 as shorthand of 1+1+1, 4 as shorthand of 1+1+1+1 and so on. What we effectively construct are strings

- 1+1+1+1+1….+1+1

of different lengths by repetition of +1. From this representation we can figure out properties of natural numbers built in by construction and understand why e. g. 2+3 = 3+2. (Can you do it?)

A leading principle will be to find properties of mathematical objects from their construction.

Recall that the mathematician Kronecker said that:

- God made the
**natural numbers**; all else is the work of man.

We shall now let the computer play God and construct the natural numbers by repetition of +1, and from that construct everything else. To our help we will then use the **web editor p5js for JavaScript** freely available on the web, which you find here.

When you open p5js you find the JavaScript template

function setup() {

createCanvas(400, 400);

}

function draw() {

background(220);

}

You see **function setup()** creating a display of size 400×400 pixels on computer screen. You can change the number of pixels. The position of a pixel on the screen is denoted by (x,y) with x and y natural numbers ranging from 0 t0 400, with x horizontal in the right direction and y vertical down.

You see **function draw()** which will repeatedly execute the program to be filled in, as fast as possible depending on the computer with a maximal rate of 60 updates per second. You can set the rate of update as frameRate(?).

You can choose the color of the background with background(0) black and background(255,0,0,255) red with maximal intensity.

With // we can put in explaining comments which are not part of the code.

We now modify the template into:

let n=0;

//Define a variable n with initial value 0.

function setup() {

createCanvas(400, 400);

}

function draw() {

background(220);

n=n+1;

print(n);

fill(0);

textSize(200);

text(n,50,200);

}

When we press the arrow to run the program we see a successive printout on the screen of the natural numbers by the command text(n,50,200) displaying n at position (50,200) with textSize(200), as well on the Console where things can be printed which are not wanted on the screen.

You are now invited to play with the program by changing the numbers and see the result, e g changing to n = n + 2;

You are invited to answer the following questions before proceeding to Session 2 where will enter into different representations of natural numbers in binary an decimal form as well as the basic operations with natural numbers of addition, subtraction, multiplication and division expressed in computer programs:

- What is the basic principle?
- What is the role of repetition?
- Is there a biggest natural number?
- Motivate why by construction 2 + 3 = 3 + 2 (
*commutative law*). Generalise. - Motivate why by construction (2 + 3) + 5 = 2 + (3 + 5) (
*associative law*). Generalise. - Motivate why 2 + 0 = 2. Generalise.

Before proceeding to the next example, get an account at p5js so that you can save your work.

Compare the above idea of repetition of +1 with Peano’s Axioms for the Natural Numbers based on the idea of “immediate successor”

*0 is a number.**The immediate successor of a number is also a number.**0 is not the immediate successor of any number.**No two numbers have the same immediate successor.**Any property belonging to 0 and to the immediate successor of any number that also has that property belongs to all numbers.*

Which idea do you find more convincing? What is the meaning/use of 5?