Advertisement
hidde663

fibonacci.bf

Aug 7th, 2018
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. >>>>+++++[>++++++++++>++++++++++>++<<<-><] create values in ansi: 000¦000¦000¦000¦049¦049¦010
  2. >-.>>.<-.>.<<< print the first 2 numbers & go back to cell 1
  3. <+<+[-<+>>+<]<[->+>>>>+<<<<<] add sequence
  4. >>>>>.>.<<<<< print 3rd number & go back to cell 1
  5. [<+>-]>[<+>-]
  6. <<[>>+<<-]
  7. >[<+>-]
  8. <[->+>+<<]
  9. >>>>->--<<< reset values in cells 5&6 to ansi48 (dec0) for later use
  10. [>+>>+<<<-]>[-<+>]
  11. >>.>.< print 4th number & go back to cell 1
  12. [-]<[-<+>] reset value in cell 6 to dec0 (ansi48)
  13. <[->+>+<<]<<< cut value from cell 4 (ansi0) in cell 5&6 (ansi48) & move to cell 1
  14. loop should start here
  15. >>[-<<+>>] move value in cell 4 to cell 2
  16. <[->+<] move value in cell 3 to 4
  17. <[->+>+<<] add value from cell 2 to cell 3 & 4
  18. >>[->+<] move value in cell 4 to 5
  19. >[-<+>>>+<<] move 5 to 4 & 7 leaving 5 empty
  20. >>.>.<[-]<[-<+>]<[->+>+<<]<<< print value & reset 6 & 7 then return to cell 2
  21. and repeat
  22. >>[-<<+>>] move value in cell 4 to cell 2
  23. <[->+<] move value in cell 3 to 4
  24. <[->+>+<<] add value from cell 2 to cell 3 & 4
  25. >>[->+<] move value in cell 4 to 5
  26. >[-<+>>>+<<] move 5 to 4 & 7 leaving 5 empty
  27. >>.>.<[-]<[-<+>]<[->+>+<<]<<< print value & reset 6 & 7 then return to cell 2
  28. etc
  29. run like this from cmd(dot)exe:
  30. Brainfuck-Interpreter-V2(dot)bat fibonacci(dot)bf
  31. Brainfuck-Interpreter-V2(dot)bat: https://pastebin(dot)com/Tr8ZMgya
  32. fibonacci(dot)bf: https://pastebin(dot)com/eEm1X732
  33. aaaand i've already made 2 mistakes
  34. First one being hardcoding the first 4 outputs
  35. Second one being not taking into consideration that the output could contain more than one value
  36. the lather being quite catastrophic
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement