Start here
Classic Algorithms in Befunge
How familiar algorithms such as factorials, GCD and sorting change shape when the only tools are a stack, a movable pointer and a small grid of cells.
Programming in Funge
Classic algorithms worked through on a grid.
Start here
How familiar algorithms such as factorials, GCD and sorting change shape when the only tools are a stack, a movable pointer and a small grid of cells.
Build a small Befunge factorial program with a loop, a scratch cell and a pass-by-pass table showing the stack and accumulator at every step.
Convert a number to binary in Befunge by repeated division, then fix the backward digit order by letting the stack hand the digits back in reverse.
Turn the remainder-based Euclidean algorithm into a tested Befunge program, with pointer paths, stack contents and a scratch cell for the missing rotation.
A tested Befunge program prints Fibonacci numbers using dup, swap and a scratch cell in place of rotation, with the stack traced pass by pass.
How the Befunge question mark sends the pointer in a random direction, with a tested coin-flip program and ways to make programs tolerate chance.
Read characters until a newline, push them on the Befunge stack, then pop and print them backward, using the stack's own ordering to do the reversal.
Without arrays, a Befunge sort stores values in grid cells and compares them pair by pair. See a tested compare-and-order routine and what a full sort costs.
A tested Befunge program checks whether a number is prime by trying each divisor in turn, and the article explains its limits in such a small language.
A 14-cell Befunge quine reads its own cells with get and prints them, showing how the playfield doubles as data. Includes a cell-by-cell explanation.
Related topics