Lesson 8
Deadfish and its one number
Deadfish has a single accumulator and four commands. i adds one, d takes one away, s squares and o prints the number in decimal and a newline. It cannot read input or loop.
The lesson
Squaring is the only way to grow fast. ii is 2, s makes 4 and s again makes 16.
Deadfish has its own page, and Run opens this example in the editor.
Example
Output
Exercise 1
Print 100.
Run tries your program on the input below. Check runs it on every test.
| Input | Expected output |
|---|---|
(empty) | 100
|
Output
A hint
3 squared is 9; one more is 10; square again.
One answer
Answer: Print 100.
Expected output
100
| Input | Expected output |
|---|---|
(empty) | 100
|
Output
Exercise 2
Print 1, 2 and 3, each on its own line.
Run tries your program on the input below. Check runs it on every test.
| Input | Expected output |
|---|---|
(empty) | 1
2
3
|
Output
A hint
o does not change the number.
One answer
Answer: Print 1, 2 and 3, each on its own line.
Expected output
1 2 3
| Input | Expected output |
|---|---|
(empty) | 1
2
3
|
Output