Created
November 25, 2019 11:37
-
-
Save olligobber/0445a1721eb22b1d5b65bb4d4becdbf6 to your computer and use it in GitHub Desktop.
Outputs all 1 byte primes using only 7 bytes of memory.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET POS 0 TO 2 | |
++ | |
WHILE POS 0 ISNT 0 | |
[ | |
SET POS 1 TO 2 | |
>++< | |
SET POS 2 TO POS 0 MINUS POS 1 | |
[->>+>+<<<]>>>[-<<<+>>>]<<[->->+<<]>>[-<<+>>]<<< | |
WHILE POS 1 ISNT POS 0 (POS 2 ISNT 0) | |
>>[<< | |
WHILE POS 2 ISNT 0 | |
>>[<< | |
SET POS 4 TO ISZERO(POS 3) | |
>>>[->+>+>+<<<]>>>[-<<<+>>>]<[<->[-<->]]<+<<<< | |
IF ISZERO(POS 3) | |
>>>>[<<<< | |
COPY POS 1 TO POS 3 | |
>[->>+>>+<<<<]>>>>[-<<<<+>>>>]<<<<< | |
END IF | |
>>>>-]<<<< | |
DECREMENT POS 2 & 3 | |
>>->-<<< | |
END WHILE | |
>>]<< | |
SET POS 4 TO ISZERO(POS 3) | |
>>>[->+>+>+<<<]>>>[-<<<+>>>]<[<->[-<->]]<+<<<< | |
IF ISZERO(POS 3) | |
>>>>[<<<< | |
RESET POS 1 | |
>[-]< | |
COPY POS 0 TO POS 1 | |
[->+>+<<]>>[-<<+>>]<< | |
DECREMENT POS 1 | |
>-< | |
SET POS 5 TO MINUS 1 AS A FLAG | |
>>>>>-<<<<< | |
END IF | |
>>>>-]<<<< | |
RESET POS 3 | |
>>>[-]<<< | |
INCREMENT POS 1 | |
>+< | |
SET POS 2 TO POS 0 MINUS POS 1 | |
[->>+>+<<<]>>>[-<<<+>>>]<<[->->+<<]>>[-<<+>>]<<< | |
END WHILE | |
>>]<< | |
RESET POS 1 | |
>[-]< | |
INCREMENT FLAG AT POS 5 | |
>>>>>+<<<<< | |
IF FLAG | |
>>>>>[<<<<< | |
OUTPUT POS 0 | |
. | |
END IF | |
>>>>>-]<<<<< | |
INCREMENT POS 0 | |
+ | |
END WHILE | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
++[>++<[->>+>+<<<]>>>[-<<<+>>>]<<[->->+<<]>>[-<<+>>]<[[>[->+>+>+<<<]>>>[-<<<+>>>]<[<->[-<->]]<+[<<<[->>+>>+<<<<]>>>>[-<<<<+>>>>]<-]<<->-<]>[->+>+>+<<<]>>>[-<<<+>>>]<[<->[-<->]]<+[<<<[-]<[->+>+<<]>>[-<<+>>]<->>>>-<-]<[-]<<+<[->>+>+<<<]>>>[-<<<+>>>]<<[->->+<<]>>[-<<+>>]<]<[-]>>>>+[<<<<<.>>>>>-]<<<<<+] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cheaty version: