After the triangular numbers, the square numbers should be a breeze:
SimCom the Simple Computer 4 We can make things easier if we write out the instructions more like the computer ... like this:
1
4
9
16
25 Check.
- Put a one in box A
- Put a three in box B
- Output box A
- Add box B to box A
- Add one to box B
- Add one to box B
- Go to step 3
LDA #1 STA A LDA #3 STA B LOOP: OUT A LDA A ADD B STA A INC B INC B JMP LOOP
This is just what we do on real computers. This sort of language is known as assembler language. Once you have written your program like this, it is much easier to convert it to the numbers that have to go into the machine.
Write the triangular numbers program in assembler and then convert it to numbers. Check.