Skip to main content
Added an explanation.
Source Link
p1xel
  • 241
  • 1
  • 5

Brainfuck, 70 bytes

+
++
+++
++++
+++++
++++++
+++++++
++++++++
+++++++++
++++++++++
--[>+<++++++]>-

GotEach line must be run individually.

The first 10 are self explanatory: we increment the value of the cell via each plus.

The 42 is a lot more complex. It relies on the fact the most brainfuck interpreter use 8-bit cells, meaning that all operations on it are done modulo 256. The -- sets cell #0 to 254. Then we enter a loop which runs until cell #0 is 0. Each iteration adds 1 to cell #1 and adds 6 to cell #0. This loops runs 43 times, so cell #1 is 43. Finally, we subtract 1 from cell #1 to make it 42.

I got the most efficient 42 ever found from http://esolangs.org/wiki/Brainfuck_constants

Brainfuck, 70 bytes

+
++
+++
++++
+++++
++++++
+++++++
++++++++
+++++++++
++++++++++
--[>+<++++++]>-

Got the most efficient 42 ever found from http://esolangs.org/wiki/Brainfuck_constants

Brainfuck, 70 bytes

+
++
+++
++++
+++++
++++++
+++++++
++++++++
+++++++++
++++++++++
--[>+<++++++]>-

Each line must be run individually.

The first 10 are self explanatory: we increment the value of the cell via each plus.

The 42 is a lot more complex. It relies on the fact the most brainfuck interpreter use 8-bit cells, meaning that all operations on it are done modulo 256. The -- sets cell #0 to 254. Then we enter a loop which runs until cell #0 is 0. Each iteration adds 1 to cell #1 and adds 6 to cell #0. This loops runs 43 times, so cell #1 is 43. Finally, we subtract 1 from cell #1 to make it 42.

I got the most efficient 42 ever found from http://esolangs.org/wiki/Brainfuck_constants

Source Link
p1xel
  • 241
  • 1
  • 5

Brainfuck, 70 bytes

+
++
+++
++++
+++++
++++++
+++++++
++++++++
+++++++++
++++++++++
--[>+<++++++]>-

Got the most efficient 42 ever found from http://esolangs.org/wiki/Brainfuck_constants