Getting started with BrainFuck


Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

Move value (aka pseudo-copy)

In order to move a value A to, say, next cell, we need to add 1 A times to the target (initially empty) cell.

It's like sum : we have A, 0 and we want 0, 0+A=A

Let's start

  • Memory: A, 0
  • Cursor: on A
  • Input: any


  • while A is not null
    • invariant: A cell + next cell = A
    • decrease A
    • increase target
  • loop
  • A cell = 0, next cell = A - 0 = A


[    while A is not null
  -  decrease A
  >+ increase target
  <  go back to A
]    loop

Minified version


Final state

  • Memory: 0, A
  • Cursor: "0" cell
  • Input: unchanged
  • Output: unchanged
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content