esolang
Learn · LessonsLesson 4 of 18

Lesson 4

A brainfuck multiplication loop

An A written out takes 65 plusses. A loop with a counter builds a large number in a few commands.

The lesson

Put 8 in a counter cell and loop. Each pass moves right, adds 8, moves back and takes one from the counter. When the counter hits zero the next cell holds 8 × 8 = 64.

This pattern, counter[>step<-], is how almost every brainfuck program builds its numbers. The example adds one more and prints A.

Brainfuck has its own page, and Run opens this example in the editor.

Example

Output


Exercise 1

Print the digit 0 (byte 48) with a multiplication loop.

Run tries your program on the input below. Check runs it on every test.

The tests it must pass
InputExpected output
(empty)0

Output


A hint

48 is 6 × 8.

One answer

Answer: Print the digit 0 (byte 48) with a multiplication loop.

Expected output

0
The tests it must pass
InputExpected output
(empty)0

Output


Exercise 2

Read a lowercase letter and print it in uppercase (subtract 32).

Run tries your program on the input below. Check runs it on every test.

The tests they must pass
InputExpected output
aA
qQ
zZ

Output


A hint

A counter of 4 in the next cell, taking 8 from the letter each pass.

One answer

Answer: Read a lowercase letter and print it in uppercase (subtract 32).

Expected output

A
The tests they must pass
InputExpected output
aA
qQ
zZ

Output


Read more