mirror of
https://github.com/sigmasternchen/fibonacci
synced 2025-03-14 23:58:57 +00:00
added brainfuck fibonacci
only works for single digit number a the moment
This commit is contained in:
parent
10c099212f
commit
8e45e34c9b
1 changed files with 57 additions and 0 deletions
57
brainfuck/fib.bf
Normal file
57
brainfuck/fib.bf
Normal file
|
@ -0,0 +1,57 @@
|
|||
++++ number of iterations
|
||||
>
|
||||
++++++++++ dec 10 = \n
|
||||
>
|
||||
++++++++++++++++++++++++++++++++++++++++++++++++ dec 48 = 0
|
||||
+.
|
||||
<.>
|
||||
.-
|
||||
<.
|
||||
>>
|
||||
+ value 1
|
||||
>
|
||||
+ value 2
|
||||
<<<<
|
||||
[ iterate
|
||||
-
|
||||
>>>
|
||||
[ copy value 1 to result
|
||||
-
|
||||
>>+
|
||||
<<
|
||||
]
|
||||
>
|
||||
[ add value 2 to result and set value 1
|
||||
-
|
||||
>+
|
||||
<<
|
||||
+
|
||||
>
|
||||
]
|
||||
>
|
||||
[ copy result to value 2 and to ascii
|
||||
-
|
||||
>+
|
||||
<<+
|
||||
>
|
||||
]
|
||||
<<<
|
||||
[ calculate ascii value; use result for dec 30
|
||||
-
|
||||
>>>+
|
||||
>+
|
||||
<<<<
|
||||
]
|
||||
>>>
|
||||
[ restore dec 30
|
||||
-
|
||||
<<<+
|
||||
>>>
|
||||
]
|
||||
>.
|
||||
[ reset ascii
|
||||
-
|
||||
]
|
||||
<<<<<.
|
||||
<
|
||||
]
|
Loading…
Reference in a new issue