Fibonacci numbers in Befunge
Example for versions
befungee 0.2.0
This example uses iterative definition of Fibonacci numbers. It is based on commands p
and g
which are used to modify source code of the program at the runtime, — they put a specific character at a certain cell of the program or read it from the cell to the stack, respectively. In this case they are used to store Fibonacci numbers outside of the stack. Loop counter is stored in the bottom element of the stack all the time. Since playfield cells can’t store values over 255, only the first 13 Fibonacci numbers are printed.
031p132p 94+ > 31g 32g :. + 32g v
| :-1,,", "p23 p13 <
> "."::,,,@
Comments
]]>blog comments powered by Disqus
]]>