Philosophical Multicore

Sometimes controversial, sometimes fallacious, sometimes thought-provoking, and always fun.

The Best BF Program I’ve Ever Written

Posted by Michael Dickens on November 9, 2009

I wrote a BF program which calculates every prime number from 2 to 100. This is it:


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

Since I’m using a slow Python interpreter, it takes a long time to finish. But it still works.

Advertisements

6 Responses to “The Best BF Program I’ve Ever Written”

  1. LRFLEW said

    I’m lost.

    for understanding, can you make a BF program that takes the number at cell-0, and change it to the next prime number up (as actual value, not as printable text)?

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

    All those +'s at the beginning indicate the first number you want to input. Right now it's 32.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: