In most programming languages, the statement `n = n + 1` is perfectly valid. It simply increments `n,` by 1 (of course, you may prefer `n++`).

When I was doing GCSE maths I had a homework involving prime numbers. I wrote a program which checked a sequence of numbers - from 1 up to a specified limit - and output their factors. My code (written in BASIC) contained at least one iterative loop, inside one of which I incremented n by 1

n = n + 1

Now my maths teacher had never seen 'programming' before. I - assuming this line was fairly self explanatory - had neglected to furnish it with a comment explaining what it did. As a result, when I got the marked homework back again, I saw red scribble around the line, and the remark

How can n = n + 1? See me.

Despite trying to explain to her that this statement is not "wrong", it just increments n by 1, I was unable to persuade her not to drop my mark.

I never even thought of trying to prove that n = n + 1.

Log in or register to write something here or to contact authors.