Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>>>+++++[>++++++++++>++++++++++>++<<<-><] create values in ansi: 000¦000¦000¦000¦049¦049¦010
- >-.>>.<-.>.<<< print the first 2 numbers & go back to cell 1
- <+<+[-<+>>+<]<[->+>>>>+<<<<<] add sequence
- >>>>>.>.<<<<< print 3rd number & go back to cell 1
- [<+>-]>[<+>-]
- <<[>>+<<-]
- >[<+>-]
- <[->+>+<<]
- >>>>->--<<< reset values in cells 5&6 to ansi48 (dec0) for later use
- [>+>>+<<<-]>[-<+>]
- >>.>.< print 4th number & go back to cell 1
- [-]<[-<+>] reset value in cell 6 to dec0 (ansi48)
- <[->+>+<<]<<< cut value from cell 4 (ansi0) in cell 5&6 (ansi48) & move to cell 1
- loop should start here
- >>[-<<+>>] move value in cell 4 to cell 2
- <[->+<] move value in cell 3 to 4
- <[->+>+<<] add value from cell 2 to cell 3 & 4
- >>[->+<] move value in cell 4 to 5
- >[-<+>>>+<<] move 5 to 4 & 7 leaving 5 empty
- >>.>.<[-]<[-<+>]<[->+>+<<]<<< print value & reset 6 & 7 then return to cell 2
- and repeat
- >>[-<<+>>] move value in cell 4 to cell 2
- <[->+<] move value in cell 3 to 4
- <[->+>+<<] add value from cell 2 to cell 3 & 4
- >>[->+<] move value in cell 4 to 5
- >[-<+>>>+<<] move 5 to 4 & 7 leaving 5 empty
- >>.>.<[-]<[-<+>]<[->+>+<<]<<< print value & reset 6 & 7 then return to cell 2
- etc
- run like this from cmd(dot)exe:
- Brainfuck-Interpreter-V2(dot)bat fibonacci(dot)bf
- Brainfuck-Interpreter-V2(dot)bat: https://pastebin(dot)com/Tr8ZMgya
- fibonacci(dot)bf: https://pastebin(dot)com/eEm1X732
- aaaand i've already made 2 mistakes
- First one being hardcoding the first 4 outputs
- Second one being not taking into consideration that the output could contain more than one value
- the lather being quite catastrophic
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement