Skip to content

Instantly share code, notes, and snippets.

@CristianoBarone
Created December 11, 2021 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CristianoBarone/c3b0776968c53131e045b8c8608b892e to your computer and use it in GitHub Desktop.
Save CristianoBarone/c3b0776968c53131e045b8c8608b892e to your computer and use it in GitHub Desktop.
Fibonacci's sequence up to 233 in BrainFuck
Fibonacci's Sequence
>+. Print 1
[<->>+<+<]
>.[>>+>+<<<-] Print 2
>[->+<]
>.[-<<+>>] Print 3
<<[<+>>+<-]
>[->>+<<<]>
>>[-<<+>>]
<<. Print 5
[>+>+<<-]
<<
[->>>+<<<]
>>>. Print 8
>[-<<+>>]
<[<<+<+>>>-]<<<
[
[->>+<<]
>>. Print from 13 to 233 (attempting to go on from 233 will cause an overflow as we're working with 8bit unsigned ints)
[-<<+>>]
<<[>+>+<<-]>
]
@CristianoBarone
Copy link
Author

Minified version:

+.>+.[<->>+<+<]>.[>>+>+<<<-]>[->+<]>.[-<<+>>]<<[<+>>+<-]>[->>+<<<]>>>[-<<+>>]<<.[>+>+<<-]<<[->>>+<<<]>>>.>[-<<+>>]<[<<+<+>>>-]<<<[[->>+<<]>>.[-<<+>>]<<[>+>+<<-]>]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment