text:
Another Euler Brick in the Wall
A Euler Brick is a cuboid where the length of all the edges are integers and all of the diagonals of the faces are integers as well. All sides must also be different.

Your program has to find as many different Euler Bricks where the sides are less than L within the time M (L and M will be defined later).
All of your calculated bricks have to be unique. This means that if your dimensions are the same, just in a different order, it must not be counted.
To calculate a brick means to find the lengths of the edges and the lengths of the diagonals of the faces of a valid Euler Brick.
Your bricks must also be indivisible by each other. In the same way that the Pythagorean triplet 6, 8, 10 is divisible by 3, 4, 5, your bricks must not be divisible by each other.
To test your program, I will need to the following:

The language your code is written in
A command to run your code
Your code

Your score will be the average number of bricks your program calculates (running the program five times). To do this, I will run your program and end it after M minutes have elapsed. Once you have submitted your answer, I will add a comment on your answer telling what your score is. If you make an edit to your code, please notify me directly so I can find your score again.
For that reason, I need your program to print the number of bricks either at throughout the running or at the end. This can be done like so (in Python it would help if people told me how to do this in other languages for this example):
try:
    # Calculation goes here

except KeyboardInterrupt: # I will use Ctrl-C
    print(numberofbricks)
    exit()

For this challenge L=10^30 and M=2 minutes. In the event of a tie, the actual time taken to calculate all of the bricks will be used. The lower time wins.
I will find your time using the script below. All programs will be tested on the same machine.
import time, subprocess
command = # How do you run your program?
s=time.time()
subprocess.Popen(command, shell=True)
e=time.time()
print(e-s)

Leaderboard
1. Peter Taylor  - 5731679685.5 bricks per minute
2. Steve Verrill - 680262303 bricks per minute
3. Beta Decay    - 0.5 bricks per minute

Why is there an [underhanded] category if they all get put on hold. "There are either too many possible answers..." which is kinda to key to obfuscation.

According to http://mathworld.wolfram.com/EulerBrick.html no "perfect" Euler brick with integral internal diagonal is known. If anyone comes  up with a viable method, the whole world maths community will congratulate them. Voting to reopen because I like to dream, but I would prefer a straight Euler Brick code challenge: (bricks found in a minute) / (bytes).

I have worked on this problem (not as a programming exercise), and so have a lot of other people. In fact, I'm sure that supercomputers have been put to this task. I don't understand the reopen votes unless the perfect requirement is removed.

@AndoDaan Good underhanded questions ask you to do one (specific) thing and pretend to do another. Questions like this here are just saying "pretend you're doing this thing, but in fact you can do whatever you want". That's what's too broad. In addition, as Steve and Eric point out, it is unlikely that it's even possible to write a program which does correctly compute the brick which means there are even less invalid programs.

Betadecay, now that you've removed the "perfect" requirement per @EricTressler's comment, this becomes a realistic problem, so I see no need for the underhanded. It's generally not a very well received tag. By the way,  Eric, we've had some well received questions about unproven conjectures before, such as this one:  http://codegolf.stackexchange.com/questions/25247/lets-take-beals-1-000-000/25556#25556

@MartinBüttner I'll have to agree with your far greater experience. Thanks for explaining.

@steveverrill The problem to which you referred was worded much differently; it was asking for legitimate methods of attempting to disprove a theorem. The analogue here would be to ask for algorithms that attempt to verify the existence of a perfect Euler brick, which I would have been in favor of. A new method for a problem like this, generally running on a cluster or something, always has a chance of proving something new.

@EricTressler I think we are saying the same thing in different ways. I would like to see the underhanded tag eliminated and the question revised in line with what you say in your last comment. I think a Euler brick question is a great idea - I like the fact that although it is unlikely that anyone would find a perfect Euler brick, at least there is some output (regular Euler bricks) on the way. However I don´t want it enough to go a ahead and edit/hijack the OP's question.

The updated winning criterion is going to lead to disputes, so it isn't fit for purpose. You need to specify how duplicate bricks should be counted (probably by specifying that the edges must be sorted in ascending order) and then you need a single benchmark which you will verify for each competitor in conditions which are as similar as possible.

Okay, much better. One more thing now: isn't your challenge trivially solved by hardcoding the smallest Euler brick and spitting out 1,000,000 multiples of it?

You could probably fix that by having a scoring like "Find the most Euler bricks with side-length less than L within m minutes." Where you pick L and m such that just producing multiples of a few hardcoded Bricks will hit L way before hitting m, but such that it's unlikely that anyone can find all bricks less than L in the given time (and if people do, the tie-breaker is the actual time they took).

Martin's proposal is probably the best solution, because at present the obvious approach is to generate one of the parametric families.

As I understand it, the scoring is now exclusively based on number of bricks found, so the code-golf tag is inappropriate. I'll go ahead and replace it with a code-challenge tag (it seems more appropriate than the fastest-code tag.

Finally. I'm glad they let this post out of jail.

At present the only output is a number of bricks "calculated". What does it mean to "calculate" a brick?

Has anyone actually attempted this challenge? I'm wonder what kind of numbers you guys are getting. I've got a program that finds like, 4 or 5 bricks in 2 minutes. It is incredibly sub-optimal, but still I was thinking Euler bricks would be more common..

@stokastic That seems much slower than I expected...

@BetaDecay I feel the same. With optimizations I feel like I could speed it up as much as 10x, but even then it will only be around 20-30 bricks per minute. I'm curious to see the algorithms other people use.

@stokastic, 29 million in 4.5 seconds, but using 1.5GB of memory. I only have 4GB of physical RAM on this machine, so that's the limiting factor for me. But at the moment I'm using the memory as write-once-read-once, and by turning it into a circular buffer I should be able to improve. Failing that there's a tradeoff which uses much less memory but much more CPU.

Just an outsider's perspective here, all of the comments make me unsure of whether this is currently a good question or not. No matter how much I think it's a cool idea. Maybe hash it out in chat next time.

It’s a little bit confusing that the picture also shows the space diagonal, which is never mentioned again.

The scoreboard looks a very imbalanced. From hundreds of millions of bricks per minute down to 0.5 brick per minute. haha

Donald Trump's favourite question on this site.

C using Saunderson's parameterisation and Berggren's tree
In 1740, Saunderson found the parameterisation that if (a, b, c) is a Pythagorean triple (i.e. a^2 + b^2 = c^2) then (a(2b-c)(2b+c), b(2a-c)(2a+c), 4abc) is a rational cuboid (this was before Euler studied them) with diagonals (c^3, a(5b^2+a^2), b(5a^2+b^2)). This doesn't generate all Euler bricks. Note that if the brick is primitive iff the Pythagorean triple is primitive.
If (x, y, z) is an Euler brick then so is (xy, xz, yz). Applying this once to a Saunderson brick creates a new brick which isn't Saunderson and which can be made primitive with division by ab. Applying the same transformation a second time gives the non-primitive xyz(x, y, z).
In 1934, Berggren discovered that the primitive Pythagorean triples form a ternary tree rooted at (3, 4, 5) which can be generated by a simple matrix multiplication and which contains each triple precisely once.
This implementation generates primitive Pythagorean triples and stores them in a stack, limiting the memory usage to 1.5GB. An earlier version used a circular buffer, but the stack gives much better results. This is probably a combination of fewer values being discarded and better cache locality.
Thanks to Steve Verrill for pointing out some bugs and for suggesting the use of a stack instead of a circular buffer. I've also followed him in removing the conjugate bricks for speed: previously the search space (minus the discarded branches) was exhausted within the two minutes, and there was value in spending time to get a few conjugates. But the new version can easily run for 5 minutes (as I discovered in the process of learning the value of the volatile keyword!), and most of the conjugates overflow, so on average the tests are wasted time.
#include <stdlib.h>
#include <inttypes.h>
#include <stdio.h>
#include <signal.h>
#include <string.h>

// Stack size. This is 1.5GB of memory.
#define N 33554432

typedef unsigned __int128 scalar;

typedef struct {
    scalar a, b, c;
} triple;

// Stack operations
#define take(st) st[--stp];
#define offer(A,B,C) if (stp < N) { st[stp].a=(A); st[stp].b=(B); st[stp].c=(C); stp++; }

volatile sig_atomic_t stop;

void handler(int sig, siginfo_t *siginfo, void *context) {
    stop = 1;
}

int main(int argc, char **argv) {
    // Register interrupt handler
    stop = 0;
    struct sigaction act;
    memset(&act, 0, sizeof(act));
    act.sa_sigaction = &handler;
    act.sa_flags = SA_SIGINFO;
    if (sigaction(SIGINT, &act, NULL) < 0) return 1;

    // L = 10^30
    const scalar L = ((scalar)0xc9f2c9cd0UL << 64) + 0x4674edea40000000UL;
    const scalar T = (scalar)1 << 64;   // used in an anti-overflow test

    // To avoid the optimiser removing the calculation of the bricks.
    int writeToStdOut = argc > 1;

    triple *st = (triple *)malloc(N * sizeof(triple));
    if (!st) return 2;

    uint32_t stp = 1; // Index of first empty space in stack
    st[0].a = 3; st[0].b = 4; st[0].c = 5;
    uint64_t count = 0;

    while (stp > 0) {
        if (stop) break;
        triple t = take(st);

        // Extend queue of Pythagorean triples
        offer(t.a + ((t.c - t.b) << 1), ((t.a + t.c) << 1) - t.b, ((t.a - t.b + t.c) << 1) + t.c)
        offer(t.a + ((t.c + t.b) << 1), ((t.a + t.c) << 1) + t.b, ((t.a + t.b + t.c) << 1) + t.c)
        offer(-t.a + ((t.c + t.b) << 1), ((-t.a + t.c) << 1) + t.b, ((-t.a + t.b + t.c) << 1) + t.c)

        // Saunderson brick
        scalar x = t.b * ( ((t.a << 1) >= t.c) ? ((t.a << 1) - t.c) : (t.c - (t.a << 1)) ) * ((t.a << 1) + t.c);
        scalar y = t.a * ((t.b << 1) - t.c) * ((t.b << 1) + t.c);
        scalar z = t.a * t.b * t.c << 2;
        scalar u = t.c * t.c * t.c;
        scalar v = t.b * (t.b * t.b + 5 * t.a * t.a);
        scalar w = t.a * (t.a * t.a + 5 * t.b * t.b);
        count++;
        if (writeToStdOut) {
            printf("Sides: 0x%016"PRIx64"%016"PRIx64, (uint64_t)(x >> 64), (uint64_t)x);
            printf(", 0x%016"PRIx64"%016"PRIx64, (uint64_t)(y >> 64), (uint64_t)y);
            printf(", 0x%016"PRIx64"%016"PRIx64, (uint64_t)(z >> 64), (uint64_t)z);
            printf("; diags 0x%016"PRIx64"%016"PRIx64, (uint64_t)(u >> 64), (uint64_t)u);
            printf(", 0x%016"PRIx64"%016"PRIx64, (uint64_t)(v >> 64), (uint64_t)v);
            printf(", 0x%016"PRIx64"%016"PRIx64"\n", (uint64_t)(w >> 64), (uint64_t)w);
        }
    }

    printf("%ld\n", count);

    return 0;
}

Compiles with gcc -O3 euler_brick.c -o euler_brick and handles SIGINT (Ctrl-C).  On my computer the earlier circular buffer version ran out of usably small Pythagorean triples after 85 seconds having found 843035517 (0.843 thousand million) Euler bricks. The new version runs to the two minutes (tested with timeout -sINT 2m ./euler_brick) and finds about 9.1 thousand million bricks. Exact numbers vary from run to run; the highest I've observed is 9113459216.
Note that this is single-threaded code. The process is embarrassingly parallel - just start each thread going down a different branch of the tree - and so the limitation to scaling it to multicore would be the shared memory bus.

Man you did your research. I had a 'similar' approach, but it was about 8 orders of magnitude more naive. I was using a similar process to generate co-prime integers which can be used to generate pythagorean triples, and then comparing linear combinations of the triples to find cuboids. I guess I didn't hit google hard enough ;)

Which version of GCC are you using because I'm getting a load of errors when I try to compile your code?

Here is what I'm getting.

@BetaDecay, GCC 4.6, 64-bit Linux. There seem to be two important differences between my environment and yours: firstly, your target apparently doesn't support __int128 (are you using a 32-bit OS?); secondly, you don't apparently have a POSIX-compliant signal.h.

I'm on 64-bit Windows 7. I'll try it on 64-bit Ubuntu 12.02

This is amazing. A couple of comments: 1.Your non-Saunderson brick isn't primitive, it's divisible by ab. 2.With recursion you can avoid the memory issue (though the brick sizes would be all over the place. Considering both of these points would increase the number of (sufficiently small) bricks found. I'm still debating whether to do my own program.

The first is an excellent point: I shall correct the program later. The second is an interesting one, but I wonder whether a tail recursion would be better because the stack could still get quite large.

I tried recursion and I do need to limit the stack size, see my answer. However I don't think I'm losing many bricks that way. I noticed another thing in your code: I'm not sure how if (x < 0) x = -x; works with an unsigned variable. I found I had to check the sign of both x and y, but I made the tree a different way.

I managed to get it working on my Ubuntu machine (Linux FTW!) and the number of bricks calculated in 2 minutes was 11463359371.

Peter, as I was getting 1.6E9 bricks of side <10^30 with my program running to completion and stack limitation was having little effect, I was surprised you got so many more. I looked at your code and I can't see a check for length, so I put one in (only on z which is the longest side) and rearranged the code slightly to make the check efficient. I get  1691332623 bricks at completion, which is slightly more than I found with my stack limited to 5000. I also added a "stack full" warning to your massive stack. As it was not displayed I assume that's all saunderson bricks of side < 10^30.

Without the length check I suspect that your program was reaching bricks of 2^128 in size and overflowing. See my edits at http://pastebin.com/4Z2YACzN . I also added a getchar() after the brick dimension display to slow it down. That shows a minor issue (that I haven't fixed):  It seems that there is underflow on y fairly early on, which means that the program is calculating some negative y's. Anyway, you deserve the win because you found the maths, and went to the effort of writing a custom stack, so I very much appreciate the bonus.

C using Saunderson's parameterisation and a different tree generation method.
This is heavily influenced by Peter Taylor's answer, and by the following page: https://sites.google.com/site/tpiezas/0021. For consistency, my variable naming convention largely follows Peter's.
Instead of using a buffer, I use recursion to generate the three children of each node of the tree. The tree I generate is equivalent to Berggren's tree, but I use a two-parameter method (mainly for interest and variation.) The parameters p and q for all integers generate a pythagorean triple a=p^2-q^2, b=2pq, c=p^2+q^2. If we want to limit this to primitive triples only, we start with the vector (2,1) and multiply by the 2x2 matrices below. This is equivalent to Berggren's / Barning's method, in which we start with the vector (3,4,5) and multiply by the 3x3 matrices below. See http://en.wikipedia.org/wiki/Tree_of_primitive_Pythagorean_triples .
Barning's matrices                       2x2 matrices
1 -2  2      1  2  2     -1  2  2        2 -1    2  1    1  2
2 -1  2      2  1  2     -2  1  2        1  0    1  0    0  1
2 -2  3      2  2  3     -2  2  3

It can be seen from Barning's matrices that the hypotenuse c of the second child of each node will be between 3 and 7 times larger than that of its parent (more advanced treatment would narrow this range.) the growth rates of the other branches are rather slower.
In practice it was necessary to limit the depth of recursion in order to avoid stack overflow (segmentation fault.) However, it seems likely that only a few bricks were lost. Peter's program runs on my machine in about 6 minutes and generates 843035517 Euler bricks. My program takes just over twice as long and generates 1688135295 bricks with recursion depth limited to 5000, or 1671621046 bricks with depth limited to 1000. Therefore the rate of generation is about the same. With depth limited to 40, 1134616080 bricks are generated, of which 1131433861 are Saunderson and only 3182219 are conjugate. And the program runs about twice as fast with the code for generating conjugate bricks commented out!
Instead of generating the conjugate brick of (x,y,z) as (yz,xz,xy) I generate a conjugate brick ab times smaller. To do this intermediate values x',y',u',v' are stored during the calculation of x,y,z,u,v,w.
#include <inttypes.h>

int writeStdOut,count=0;

typedef __int128 scalar;

scalar L=(scalar)1000000*1000000*1000000*1000000*1000000,T=(scalar)1<<124;

f(scalar p, scalar q, int depth){
  scalar p2,q2,
         a,b,c,a2,b2,c2,
         uprime,vprime,u,v,w,
         xprime,yprime,x,y,z;

  p2=p*p;q2=q*q;
  a=p2-q2;b=p*q<<1;c=p2+q2;

  z=a*b*c<<2;
  if(z<L){
    a2=a*a;b2=b*b;c2=c*c;

    xprime=(b2<<2)-c2;yprime=(a2<<2)-c2;
    if(xprime<0)xprime=-xprime;if(yprime<0)yprime=-yprime;
    x=a*xprime;y=b*yprime;

    uprime=b2*5+a2;vprime=a2*5+b2;
    u=a*uprime;v=b*vprime; w=c2*c;

    count++;
    if (writeStdOut) {
      printf("Sides: 0x%016"PRIx64"%016"PRIx64, (uint64_t)(x >> 64), (uint64_t)x);
      printf(", 0x%016"PRIx64"%016"PRIx64, (uint64_t)(y >> 64), (uint64_t)y);
      printf(", 0x%016"PRIx64"%016"PRIx64, (uint64_t)(z >> 64), (uint64_t)z);
      printf("; diags 0x%016"PRIx64"%016"PRIx64, (uint64_t)(u >> 64), (uint64_t)u);
      printf(", 0x%016"PRIx64"%016"PRIx64, (uint64_t)(v >> 64), (uint64_t)v);
      printf(", 0x%016"PRIx64"%016"PRIx64"\n", (uint64_t)(w >> 64), (uint64_t)w);
    }
    if(T/a/c>xprime && T/b/c>yprime){
      x=a*c*xprime<<2;y=b*c*yprime<<2; if(x<0 | y<0)puts("overflow");
      if(x<L && y<L){

        z=xprime*yprime;
        u=uprime*yprime;v=vprime*xprime;w=c2*c2<<2;
        count++;
        if (writeStdOut) {
          printf("SIDES: 0x%016"PRIx64"%016"PRIx64, (uint64_t)(x >> 64), (uint64_t)x);
          printf(", 0x%016"PRIx64"%016"PRIx64, (uint64_t)(y >> 64), (uint64_t)y);
          printf(", 0x%016"PRIx64"%016"PRIx64, (uint64_t)(z >> 64), (uint64_t)z);
          printf("; diags 0x%016"PRIx64"%016"PRIx64, (uint64_t)(u >> 64), (uint64_t)u);
          printf(", 0x%016"PRIx64"%016"PRIx64, (uint64_t)(v >> 64), (uint64_t)v);
          printf(", 0x%016"PRIx64"%016"PRIx64"\n", (uint64_t)(w >> 64), (uint64_t)w);
        }

      }
    }
    if(depth<40){f((p<<1)-q,p,depth+1);f((p<<1)+q,p,depth+1);f(p+(q<<1),q,depth+1);}
  }
}

main(int argc, char **argv){
  writeStdOut=argc>1;
  f(2,1,0);
  printf(" %d bricks",count);
}

Your answer deserves to get you at least as much rep as mine got me. Thanks for pointing out the bugs and for suggesting a massive improvement.

I had to modify your code to include a signal interrupt, but after 2 minutes your code calculated 680262303 bricks.

Thanks for the bonus @PeterTaylor! I had started thinking about some rather more naive ideas when I saw your answer. All I did was copy your maths. I've finally got round to running your code today. I will comment soon.

Python 3 - Brute forcing it
Edit: This produces a measly 0.5 bricks per minute...
To get the ball rolling again, I decided to write a simple entry. As always with brute force methods, it's extremely slow.
def mult(x,y):
    c=0
    for i in range(len(x)):
      if y[i]%x[i]==0:c+=1
    if c==3:return True
    return False

pyth=lambda x,y:True if (x**2+y**2)**0.5==int((x**2+y**2)**0.5) else False
prev=[]
ymax=245
zmax=269
try:
    for x in range(44,10**30):
        for y in range(117,ymax):
            ymax+=1
            for z in range(240,zmax):
                zmax+=1
                curr=[x,y,z]
                eq=0
                ml=0
                for i in range(3):
                    for j in range(3):
                        if i!=j:
                            if curr[i]==curr[j]:
                                eq+=1
                for k in prev:
                    if mult(curr, k):
                        ml+=1
                if eq==0 and ml==0:
                    f=pyth(curr[0],curr[1])
                    s=pyth(curr[0],curr[2])
                    b=pyth(curr[1],curr[2])
                    if f and s and b:
                        prev.append(curr)
except KeyboardInterrupt:
    print('\n\n'+str(len(prev)))

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Possibly quit your job with a polyglot
Despite your protest, you have been put to work by your boss on a program that takes a single unsigned integer as input and prints the string "prime" if that integer is prime and "not prime" if it isn't. You may choose which language you do this in, as long as the resulting program is short; your boss very much appreciates a low character count. (He will actually manually count the characters after he prints out the source code.)
So you better get to it, the lowest character count wins.
The fun part
This is just between you and me, but your program should also be valid in another language. In this language though, it should print the string "If the boss finds this, I quit.". Make sure that your boss does not figure out there is a hidden insult when reading the code over and over as he keeps forgetting if he'd counted to 17 or 18 so far. For that reason you may not use any of the words in "the boss finds this quit" in part of the code nor can you use and anagrams of those 5 words.
Bonus challenge which I have created a bounty for
Write a program that actually looks like it just solves the first question to the untrained eye and doesn't seem to contain unnecessary characters. This includes comments and segments of code that obviously don't contribute anything. Ideally, a layman would believe that your program is actually as short as it can be without being unmanagable. A helpful comment here and there is okay though.
The rules for the bonus challenge are a bit looser, instead of being judged on easily measurable criteria, your program will be judged more on how it comes accross to me (and the voters of course)
I will be the final judge of which entry comes closest to deserving this bounty.
Edit:
After a few minutes of your boss counting, he had one of your colleages write a character counting program for him. So even characters that aren't visible count towards your character count.

Well, Whitespace people will have an easy time here.

Unfortunately, the shortest possible Whitespace program which prints that message is 372 characters.

Do we need to print a trailing newline?

But the boss will print it out and count the characters. Trailing whitespace won't count.

@Martin no, no whitespace required.

The bounty challenge sounds interesting but will no doubt be won very trivially by a "well documented and indented" program in an arbitrary language (with the hidden one being whitespace).

@MartinBüttner Since the shortest possible whitespace program that does this is apparently 372 characters, I doubt this program will satisfy a boss who wants a short program. I'll add that it also needs to seem like it couldn't be much shorter to a layman.

So far, all of the entries are obviously not serious programs (random gibberish, etc.). It would be really interesting if someone made a polyglot (that doesn't include Whitespace, of course) that actually looked reasonable at first glance (even if it was really, really long).

@Doorknob that'd be easier if it was popularity contest. Since hiding it is not required and it's code golf, the current kind of submission makes more sense. I agree, though, that that'd be interesting too.

@ThreeIfByWhiskey you can't prove it

@pqnet I can prove I was wrong, though. See my answer below for a 330-character approach that I suspect might be optimal.

@overactor Can you please clarify whether whitespace and/or newlines count towards the character count?

@IngoBürk I added an edit to the question.

CJam (GolfScript), 60 59 bytes
"Jg!uif!cptt!gjoet!uijt-!J!rvju/"{(}%S#];"not prime"limp4*>

Thanks to @mnbvmar for golfing off 1 byte!
How it works (CJam)
"Jg!uif!cptt!gjoet!uijt-!J!rvju/"  " Push that string.                                    ";
{(}%                               " Subtract 1 from each character code.                 ";
S#                                 " Find the index of the first space.                   ";
];                                 " Wrap the entire stack in an array and discard it.    ";
"not prime"                        " Push that string.                                    ";
li                                 " Read an integer from STDIN.                          ";
mp4*                               " Push 4 if it's prime and 0 if it isn't.              ";
>                                  " Remove that many chars from the start of the string. ";

Try it online!
How it works (GolfScript)
"Jg!uif!cptt!gjoet!uijt-!J!rvju/"  # Push that string.
{(}%                               # Subtract 1 from each character code.
S#];"not prime"limp4*>             # Noop followed by a comment.

Try it online!

+1: The boss is gonna love how short this is. And he definitely won't see the hidden string. He might also have trouble seeing the prime check, though. :)

Let's hope he believes the hidden string is the prime check.

Python 2 / Python 3 - 128
n=int(input())
s="Isf  tthhies ,b oIs sq ufiitn.d"
print(["not "*any([n%a<1for a in range(2,n)])+"prime",s[::2]+s[1::2]][1/2>0])

Identifies prime numbers with Python 2, get's you into trouble with Python 3.

Bonus

__help__ = """In the forloop I'm setting the values i to n.
To be a "notPrimes", it's n % i == 0 if: 1 < i, i < n. (We
do tests i<1/2 i==1, too). Then, prints resulting, prime text.
In case i==n: quit. Just if it aborts: try."""

# read integer from command line
n=int(input())

try:

    # primes = True
    notPrimes = False

    # try each i to n
    for i in range(n):

        # ignore 0 or 1
        if i < 1 / 2 or i == 1:
            continue

        # test divisibility
        if n % i == 0:
            notPrimes = True

    # print result
    if notPrimes:
        print("not prime")
    else:
        print("prime")

except:

    # if program aborts: print help and error code
    print(__help__ [::7])

Try it with Python 2 or Python 3! (In contrast to the golf version above the roles changed: Python 3 is the prime number identifier. Python 2 contains the Easter egg.)
Please, excuse my bad English in the help text! ;)
And I do use the word "quit". But somehow I need to describe when my program terminates. ;)

exit?  stop?  abort?

@MooingDuck: You mean I could use one of these words? No, then it would not work. ;)

Is this the "/ problem"? (integer division vs. floating point division)

@hlt: spoiler

The second one blew my mind - until I looked a bit closer. It seems that I too have fallen into the habit of reading comments rather than code.

The second one is really nice! Kudos!

That is brilliant!

If you're in Python, do exit()

I was convinced until [::7]

Bonus submission (C / C++11)
Primality testing using the usual naive method is so mainstream. That's why I have invented a brand-new randomized naive method! This test is as follows:

Choose any integer d at random. It must not be smaller than 2 and larger than a bit more than sqrt(n).
If d is a divisor of n, output not prime.
If we made this test 20sqrt(n) times, output prime, else repeat.

If the number is composite, there is only very little probability (about 10-9) that it doesn't work. Of course, I don't believe the C/C++ pseudorandom number generator is powerful enough. That's why I use my own 256-bit LFSR generator!
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

/* A 256-bit linear feedback shift register generating pseudorandom
 * numbers (its period is 2^256 - 1).
 */
struct LFSRGenerator {
    unsigned seed[8];
};

void lfsr_init_generator(struct LFSRGenerator *gen){
    gen->seed[0] = 0xE840CC92; gen->seed[1] = 0xC440CAD0;
    gen->seed[2] = 0x40E6E6DE; gen->seed[3] = 0xC8DCD2CC;
    gen->seed[4] = 0xD0E840E6; gen->seed[5] = 0x4058E6D2;
    gen->seed[6] = 0xEAE24092; gen->seed[7] = 0x145CE8D2;
}
void lfsr_proceed(struct LFSRGenerator *gen){
    // LFSR taps are x^256, x^254, x^251 and x^246
    unsigned new_bit =
        ((gen->seed[7]>>0)^(gen->seed[7]>>2)^
         (gen->seed[7]>>5)^(gen->seed[7]>>10)) & 1;

    // shift seed right
    gen->seed[7] >>= 1;
    int cell;
    for(cell = 6; cell >= 0; cell--){
        gen->seed[cell+1] |= ((gen->seed[cell]&1)<<31);
        gen->seed[cell] >>= 1;
    }
    gen->seed[0] |= (new_bit<<31);  // put new bit
}
void lfsr_error(struct LFSRGenerator *gen){
    fprintf(stderr, "Error! Developer info:\n");

    int cell;
    for(cell = 0; cell < 8; cell++){
        unsigned val = gen->seed[cell];
        putc((char)(val&0xFF), stderr); val >>= 8;
        putc((char)(val&0xFF), stderr); val >>= 8;
        putc((char)(val&0xFF), stderr); val >>= 8;
        putc((char)(val&0xFF), stderr);
    }
    putc('\n', stderr);
    exit(1);
}
int lfsr_get_num(struct LFSRGenerator *gen, int min_val, int max_val){
    lfsr_proceed(gen);
    int mod_num = max_val-min_val+1;   // = number of possible results
    if(mod_num <= 0)
        lfsr_error(gen);

    // take 6 first cells and compute them mod 'modNum'
    unsigned long long result = 0;
    int cell;
    for(cell = 5; cell >= 0; cell--){
        result = ((result << 32) | gen->seed[cell]) % mod_num;
    }
    return (int)result + min_val;
}

/**********************************************************************/

void end_not_prime(){
    printf("not prime\n");
    exit(0);
}
void end_prime(){
    printf("prime\n");
    exit(0);
}

int main(){
    int number;
    struct LFSRGenerator gen;
    lfsr_init_generator(&gen);

    printf("Provide a number to check its primality: ");
    scanf("%d", &number);

    if(number <= 1){
        end_not_prime();
    }
    if(number == 2){
        end_prime();
    }

    // just to make sure:
    //  * make 20*sqrt(n) tests
    //  * generate random divisors from 2 to 111111/100000 * sqrt(n)
    //      (in case max range doesn't include sqrt(n)
    auto num_checks = (int)floor(sqrt(number)*20);
    auto max_range = sqrt(number);
    max_range /= 100000;
    max_range *= 111111;
    max_range = floor(max_range+0.5);

    while(num_checks--){
        int rnd_div = lfsr_get_num(&gen, 2, max_range);
        if(number % rnd_div == 0){
            end_not_prime();
        }
    }
    end_prime();
}

C++11 works correctly. However, C compiler seems to be outputting a faulty program for n > 2...
Note: remember that C needs -lm option (link math library) to compile successfully.

 Look at max_range variable. C++11 keyword auto resolves to a "matching type" - in this case double. However, in C it's defined as a variable modifier (as static is) - it doesn't define the type. Thus max_range type is a default C type, that is int. When we "try" to multiply this variable by 1.11111, in C it gets "unintenionally" zeroed during division by 100000. We get an incorrect interval of random numbers to be generated and LFSR after proceeding its internal state generates an error, outputting the binary dump of the seed. That's "accidentally" The message If the boss finds this, I quit.\n

If you find the following faulty output:
Error! Developer info:
If the boss finds this, I quit.

incorrect, just remove the appropriate fprintf line.

It looks pretty convincing. Care to explain a little, so I don't have to dig out my compiler? :)

OK, I added it.

This is amazing!

Very nice! Best answer so far, in my opinion.

Really impressive!

Wow...I've never seen something this underhanded ever on this site. +100

Mathematica/Brainfuck, 260
If[PrimeQ[Input[]],"prime","not prime"](*++++++++++[>+++>++++>+++++++>++++++++++>+++++++++++<<<<<-]>>>+++.>++.<<<++.>>>>++++++.<++.---.<<<.>>>---.>-----.++++..<<<<.>>>++++.+++.>-----.<-----.>+++++.<<<<.>>>>+.<++++.+.>-.<<<++++.<.>>.<<.>>>>--.++++.<.>-.<<<++.*)

Olson! This code is several times longer than it needs to be! What are all these unnecesary pluses and greater than signs for? You're fired! No, sir, I think you'll find I quit.

@steveverrill That's one way of quiting your job I suppose.

Golfscript / Javascript (126 125 129 130 132 134 205 207)
Try Golfscript here and Javascript here.
1.//"Jg!uif!cptt!gjoet!uijt-!J!rvju/"{(}%'
alert((/^1?$|^(11+?)\1+$/.test(Array(+prompt()+1).join(1))?"not ":"")+"prime");';#'

I'd say it's shockingly close to those Mathematica solutions which, afterall, have a built-in check for prime numbers.
Edit: Thanks to Peter for saving another two six bytes!
Here's some details:

The first 1. is needed because the following // is a comment in Javascript, but performs division twice in Golfscript. This will error out if nothing is on the stack, so we need to give it two numbers. Incidentally, 1. is a perfectly valid syntax in Javascript and will just be ignored.
"…"{(}% takes the string, decrements their character code values by one and pushes it as a string. This results in the string we need to print.
' starts a string in Golfscript which by default extends over several lines, causing the Javascript below to only be put into the string.
Next is the Javascript code, which uses a somewhat well-known approach to detect prime numbers through regular expressions.
';#' closes the multi-line string in Golfscript, discards it and then ignores the rest of the line. In Javascript, this is simply a string literal which will be ignored.

In GS 1+ is ). And 1 1 is 1., which I suspect the JS would be as happy with as 1

@PeterTaylor Awesome, thanks! I've incorporated it.

Also, if you map something over a string you get a string, so {)}/]""+ could just be {)}%.

@PeterTaylor You're the man! :)

This prints "my boss" instead of "the boss". Other than that, nice one.

@overactor Ugh, same mistake here. Shame on me. I'll have to fix it later tonight, though.

@overactor Done. It's also all printable characters now. :)

+prompt()+1 -> -~prompt() for 1 byte less and should have no effect on GS.

CJam/Ruby, 132 95 91 87
0_0#;;limp4*"not prime">"
'Li#wkh#ervv#ilqgv#wklv/#L#txlw1'.bytes{|b|print (b-3).chr}#";

My previous solution was significantly over-engineered; this one was heavily inspired by Martin Büttner's solution, including his realization that the #bytes method can apparently take a block.
How does it work?
Ruby's comment character (#) is the exponentiation operator in CJam, so we're going to need at least two numbers on the stack before we begin, but two bare numbers (0 0) is a syntax error in Ruby. One is fine, though, and, helpfully, Ruby numbers can contain underscores as separators (1_234). _ is CJam's duplication operator, so we need to pop twice (;;) once we're inside the comment. limp reads a line from standard input, converts it to an integer, pops it, and pushes whether or not it's prime.
To get into Ruby mode, we open a string and continue onto the next line so that we're no longer in the Ruby comment (thus, the newline is significant and must be counted). Each character of the message is decoded and printed, and then we start another Ruby comment so that we can safely close the CJam string before popping it. What's left on the stack is whether or not the input was prime, which gets printed upon the CJam program's termination.
CJam/Whitespace, 353 (25 meaningful when printed) characters
Given the underhanded nature of the challenge, and the fact that the boss will be printing our programs in order to count the characters, I took up the suggestion of doing a solution involving Whitespace.
Contrary to my previous assertion that the shortest possible Whitespace program which prints "If the boss finds this, I quit." would be 372 characters, this one does it in 330. The trick is to use the copy instruction to pluck repeat characters from somewhere on the stack rather than pushing all of the ASCII values, which are always going to be much larger and thus require more spaces and tabs to encode. Here's a pseudo-assembly representation of the program for the curious:
push 0
push . push t push i push u push q
push 32 push I
copy 1 push , push s copy 7 push h copy 10
copy 5 copy 4 push d push n copy 6 push f
copy 5 copy 5 dup push o push b
copy 4 push e copy 14 copy 14
copy 3 copy 10 copy 23

0: dup jz 1 ochr jump 0
1: exit

It's deprecated but it works: http://www.ruby-doc.org/core-2.1.2/String.html#method-i-bytes

It works for #chars and #lines as well, which I'll have to keep in mind for future challenges.

I thought I tried with chars and it didn't work for some reason.

You can use a variable such as L instead of "", and I don't think you need the + and the \

In fact, you can use limp4*"not prime"> to make it even shorter

@aditsu Thanks for the suggestion! That shaved another four characters.

Not counting whitespace and tabs is not fair and should be invalid. They are, by all means, meaningful as leaving them out would cause it not to work.

The prompt specifically mentions that the boss will be printing the programs before doing a character count, so I thought this was a fittingly underhanded solution.

True. I'd like clarification from @overactor for this. This decreases the count for other solutions as well because newlines wouldn't count, unless the boss thinks like a typewriter.

OP has clarified that whitespace does count towards the score.

I like how this starts with "0_0".

Bonus Prize Submission (Perl / B?f?n?e-?3)
Edit: I originally forgot to actually print the sentence and then noticed it would print it in reverse order. I noticed this after being done. I was about ready to kill a kitten, but I fixed it now.

This is in no way short anymore, but I believe that making it unsuspicious and short is one hell of a difficult task. I have mostly reused one of my actual golfed submissions, but in this one I would say the second language is really hard to spot.
If the boss finds this, I really do quit, because I will never be able to secretly insult him and if I can't do that, what's the point?
# ^ Prime Checker ([>:#,_@| Golf Inc. Ltd. | @_,#:<])
# ^ Ingo Bürk, (C) 2014
################################################################################################
# Input should be a "reasonably"
# small integer, or I can't guarantee
# that the check is fast at all.
#
# More Details:   - the numbers 0 and 1 are
#                   handled as not prime,
#                   even if some people disagree
#
#                 - because my employer prefers shortness
#                   over well-tested, modular and
#                   somewhat pretty code, the used method is
#                   somewhat questionable

#                 - first of all, the input is converted
#                   into a string of 1s such that the
#                   number of 1s equals the input;
#                   directly after that, a regexp is applied
#                   such that it checks if the input is prime

#                 - the regexp is not really my work, so I
#                   have to give attribution to its author
#                   if I want to use it here; I got it on
#                   stackoverflow:
#                   "http://stackoverflow.com/questions/3296050/how-does-this-regex-find-primes"

# <=> <--- a riddle^^
    use v5.10;

# Definition of prime number:
#############################
# "A prime is a positive integer with exactly two unique divisors."
# ,
#
# I should mention that input is given via stdin.
#
# quality documentation like this is why I get paid so much.
# use this script at your own risk.
# it has been known that checking primes like this can crash interpreters.
# this never happened to me, though.
# .
# "Less is more" -- Robert Browning (1812-1889) [Riddle Solution]

    print"not "if(1x shift)=~/^1?$|^(11+?)\1+$/;say"prime"

Bending and Breaking of the Rules:

I am using the word "the" in there, but it's not the "the" that gets printed. It might be technically invalid, I'll let the OP decide if the rules have to be this strict for the bonus challenge. If so, then so be it.
The rules state I cannot use certain words, but we read from left to right, so I assume having the words written out vertically is valid.
I have no idea how I still got this job, seeing the terrible things I write in comments. I mean: riddles, really?

Yay, another worthy competitor for the bonus bounty! :)

I see no problem in allowing this for the bonus question. I'd like to see some more explanation about how the Befunge program works by the way.

@overactor Thanks. I can add some explanations tomorrow, but stepping through the code e.g. here will show you how it works, too.

@overactor It seems that the code follow certain 'arrows' (^ = move up). Certain letters of comments are placed on a stack, which is printed out at the end, printing If the boss finds this, I quit. See the example via the URL in Ingo's reaction: "!dlrow olleH">:#,_@

The boss might complain about too much documentation. It also contains some suspicious characters.

@tbodt He might also complain about riddles in the documentation. ;)

FWIW, 0 and 1 aren't prime because that would violate the fundamental theorem of arithmetic.

@Ian Mallett I know that, but still a lot of people disagree. They just treat it as a special case.

@IngoBürk aye; many in particular want 1 to be prime (and most people who aren't-mathematicians-but-generally-get-the-idea-of-primes think it is).

Mathematica/Ruby, 115 106 bytes
The Mathematica part was slightly inspired by Peter Olson's submission, but the polyglotting with Ruby is a bit more elaborate here.
#If[PrimeQ@Input[],"","not "]<>"prime"&@1(*
"Jg!uif!cptt!gjoet!uijt-!J!rvju/".bytes{|c|print (c-1).chr}#*)

Ruby works, because the two # comment out everything that's Mathematica. The reason why Mathematica works is a bit more interesting. The code I want to execute is:
If[PrimeQ@Input[],"","not "]<>"prime"

But that's not valid Ruby, so I need to add a # somewhere. # is Mathematica's parameter for anonymous functions. So I put # at the front, which multiplies the argument with the result of the If. Yes, it will multiply that with a string, whatever that means. Then I turn this into an anonymous function with & and call it immediately with argument 1. Well, Mathematica is clever enough to know that multiplication by 1 is always the identity and only outputs the string. Afterwards, the Ruby code is simply put in a block comment.

C (Bonus Submission)
The C version is a prime checker, input array at the top.
Try to guess what language yields If the boss finds this, I quit. (It's not Whitespace).
// input numbers
unsigned z[] = {4};
// number of inputs
int n = 1;

int bad(unsigned);
int good(unsigned);
// [ ... ] is used to group code into blocks to make the code easier to understand
main(c){
    if(c != 1){
        // someone needs help running this program!
        // goto the end where help text is displayed!
        // remember: gotos are not evil
        goto helpme;
    }
    int i;
    // looping down is faster than using ++
    for(i = n; i--;){
        // first we check if input is divisible by two
        // checking out of loop because `>>` is faster
        //  than `/`

        // must be either greater (not divisible by 2) or equal (divisible by 2)
        unsigned y = z[i];
        if(y > (y>>1)*2){
            // is not divisible by 2
            // we must check every other number now to ensure primality
            unsigned j;
            for(j = 3; j < z[i]; ){
                // check if number is divisible by j

                // make another copy of z[i]:
                unsigned k = z[i];

                // compilers are stupid-they have a tendency
                //  to generate really slow code for division
                //  outside of a while loop conditional
                // therefore we do division by repeated subtraction
                // [
                    // repeated subtraction-subtract until k is less than j
                    while(k / j){
                        k -= j;
                    }
                    // if k is zero-k is divisible by j and is not a prime
                    if(!k){
                        break;
                    }
                    // bring k back down to zero-there could be
                    // memory issues if we don't-very bad
                    // afterwards continue the loop
                    while(--k > 0);
                    // increment j to continue checking
                    //  we undo if we overflowed
                    //   so we don't enter an infinite loop
                    j += 1;
                    if(j < 1){ // overflow check
                        j = 4294967295u; // max unsigned int size
                    }
                // ]
            }
            // if j >= y then y must be a prime.
            // but if j < y then j < z[i] and j must be a factor
            // j - y == 0 is used to test this-if true y is a prime
            // [
                if(j - y == 0){
                    // yay - a prime!
                    // subtraction necessary as good() and bad()
                    //  shift the value printed by 1 (who knows why)
                    good(y-1);
                }else{
                    // not a prime - oh no!
                    // output this number as not a prime
                    bad(y-1);
                }
                // we are done >+–__-+<   x_x finally! >_<
            // ]
            // >.< nearly done
            // cleanup: if y or j < 0 do -- until they are 0-
            //  avoiding memory issues is vital
            while(--y); while(--j);
        }else{
            // is divisible by 2
            // determine if this is a prime: only a prime if is 2
            // also must be non-zero
            // [
                if(!y-- || y > 1){
                    // uh oh: not a prime
                    // output
                    bad(y);
                    // undo changes to the number
                    ++y;
                }else{
                    // prime
                    // output
                    good(y);
                    // undo changes to the number
                    y += 1;
                }
                // done here <__≥ coding is exhausting
            // ]
            // clean up! clean up! everybody everywhere!
            while(y)
                // use ++ because its faster here
                // seriously: we profiled it
                ++y;
        }
    }
    return 0;
    helpme:
    // ++-++-++-++-++-++-++-++-++-++-++-++
    // +    the dreaded HELP section     +
    // ++-++-++-++-++-++-++-++-++-++-++-++
        printf("This program checks the primality"
               " of hard coded constants\n"
               "Do not run with any arguments.\n"
               "\n");
        printf("Please press any character to see more information >");
        getchar();
        printf("This is version 1 of the primality checker.\n"
               "If your version is >=1 it is new enough to work\n");
    return 0;
}

// this prints the number x+1
//  (used because profile tests have shown it to be
//   marginally faster)
print_number(unsigned x){
    x += 1;
    // scanf is way to slow.
    // itoa is nonstandard - unacceptable for an important program
    //   such as this primality checker!
    // we are using a loop here - recursion is dangerous and should
    //   be avoided at all costs!
    // recursion is also absurdly slow - see recursive fib() for
    //   an example.
    int i;
    // start from the highest place then move down all the way to the ones place
    for(i = 4000000000u / (1 << 2); i; i /= 10){
        int k = x / i % 10;
        // arrays are best avoided.
        // switches make the code convoluted
        //   so we use if chains
        if(k >= 9){
            putchar('9');
        }else if(k >= 8){
            putchar('8');
        }else if(!(--k - 6)){ // after a single round of profiling
                              // it was determined that these
                              // particular checks were optimal.
            putchar('7');
        }else if(4 <= --k - 0){ // a check with the -0 was shown to
                                // be marginally faster on one test
                                // than without the -0.
            putchar('6');
        }else if((++k + 1) / (4 + 1)){// it's optimal! really..
            putchar('5');
        }else if(3 <= k){ // constant first to avoid problems with missing `=`s.
            putchar('4');
        }else if(k > 0 && k / 2 > 0){
            putchar('3');
        }else if(++k + 1 == 1+2){ // this secret optimization is a company secret.
            putchar('2');
        }else if(++k + 42 == 44){ // another top secret company secret.
            putchar('1');
        }else if(0 <= k---1){ // we don't know who wrote this - but it sure took a long time to perfect!
            putchar('0');
        }
    }
    return i-i; // allows for a tail nonrecursion optimization.
}

bad(unsigned c){
    int *q = (int *)&c;
    if(c >= 0) // minor optimization: this was a nanosecond faster one time
        print_number(c);

    // some bit fiddling optimizations
    --*q;
    *q = -*(char *)q ^ (int)(-c * 0xBAADF823 - 43.23);
    if(*q < ++*q) *q &= +*q * 0x4AF0 + 3 ^ (int)+0x79.32413p23;

    // <.> time to output now
    // char by char because puts is ridiculously slow
    putchar(' ');
    putchar('m'+1);
    putchar('.'*'>'%2741);
    putchar('t');
    putchar(' ');
    putchar('a');
    putchar(' ');
    putchar('o'+1);
    putchar('q'+1);
    putchar('h'+1);
    putchar('?'+'.');
    putchar('7'+'.');
    putchar('<'-'6'/2);
    putchar(('.' << 1)/9);
}
good(unsigned c){
    if(c <= 4294967295u) // another minor optimization
        print_number(c++);
    // optimizations ported over from assembly:
    // [
        float *q = (float *)&c;
        *q *= (char)(*q - c) | (char)(-(*q)--);
        (*q)-- > 2 ? *q += 1 : (*q = *q*c < c);
    // ]
    if(!(4294967295u > c + 23.3))
        // >.> these optimizations >>.<< are really <.> hard to write
        --c;

    // char by char once more.
    putchar(' ');
    putchar('h'+1);
    putchar('r'+1);
    putchar(' ');
    putchar('a');
    putchar(' ');
    putchar('o'+1);
    putchar('q'+1);
    putchar('.'*'n'/'0'); // division by zero > no division by zero.
    putchar(('<'*'-'/'.'<<3)%355);
    putchar('d'+1);
    putchar(' '+1);
    putchar('\n');
}
// end of program. the cake is a lie!

The other language:

 Brainfuck. Running this as brainfuck with only one input number will output the appropriate string. Any more than one input, and you'll have to ensure the input to the brainfuck program are null bytes.

Oh god, I think I've seen code like this...

@KristofferSHansen Not in production, I hope...

Nice brainfuck:D

Perl / Befunge-93 (108 106 110)
My second submission, just because. Also uses regular expressions. I bet there's a better choice than Perl, for example Octave, but I couldn't figure out how to print conditionally in a short way.
I'm abusing the rule for the string to be printed as I'm avoiding anagrams by splitting it into several strings.
# ".t""iuq I ,s""iht s""dnif s""sob e""ht fI">:#,_@
print"not "if(1x shift)=~/^1?$|^(11+?)\1+$/;print"prime"

The number to check is taken from stdin.

Edit: I wrote "my" instead of "the" accidentally, fixing it costed +1 byte.
Edit: using if instead of unless saved 4 bytes.
Edit: Forgot about "the", splitting that one as well costed +2 bytes.

The befunge near fades into the background. It's hard to notice. Well done.

Small objection, it should be "if the boss" instead of "If my boss" This is my favorite submission so far though.

@overactor Ah, you're right. I promise it wasn't an attempt to cheat, I just hacked it together after having the idea for it during a meeting :) I fixed it, thanks!

I'd argue that the boss might notice the backwards message in the code.

Unfortunately using anagrams of the words in the hidden sentence is against the challenge rules (backwards words are anagrams).

@Igby Largeman none of the forbidden words are in the source as an anagram.

Strangely I thought there were more, but you have left one forbidden word exposed: the.

@Igby Largeman ah, rats. You're right. I'll fix it. I think what fooled you about more words might have been "find" ;)

Python 2 / Rot13 - 270 Bytes (69 not counting comments)
#Code is commented in both English and Esperanto to be more future proof.

#Read number and convert to int.
#Vs gur obff svaqf guvf, V dhvg.
x=input()

#Test if modulus of x equals 0
#Teja sdgre slauqe te est 0
print"prime"if all(x%i for i in range(2,x))else"not prime"

This uses a very simple (i.e. inefficient) algorithm.  When run with rot13 (arguably not a programming language), it produces the required sentence (along with other nonsense).
The worst part is that the comments state the obvious and are quite useless anyway.
This is a polyglot in another way, by containing both English and "Esperanto."  I hope the boss isn't a polyglot himself.

Hmm, certainly doesn't look like Esperanto at all.

Lua/PBrain(procedural Brainf*ck) - 813
Heh... Sorry, got caught up in trying to be devious.
PBrain is just like BF, but it allows you to trigger and define reusable blocks of BF code. It's use was completely unnecessary.
--Blua

x00=[[--(>++++++[>++++++<-]>----)
:<<:+++++++++.[-]<<:<<:<<:++++++.[-]>>++++++[<+++++>-]<++.<
<<:<<:<<:<<:------------.[-]<<:<<:<<:++++++++.[-]<<:<<:<<:+++++.[-]>.<
<<:<<:<<:++.[-]<<:<<:<<:<<:-----------------.[-]<<:<<:<<:<<:-------------..[-]>.<
<<:<<:<<:++++++.[-]<<:<<:<<:+++++++++.[-]<<:<<:<<:++++++++++++++.[-]<<:<<:<<:++++.[-]<<:<<:<<:<<:-------------.[-]>.<
<<:<<:<<:<<:------------.[-]<<:<<:<<:++++++++.[-]<<:<<:<<:+++++++++.[-]<<:<<:<<:<<:-------------.[-]<<:++++++++++++.[-]>.<
<<:<<:+++++++++.[-]>.<
<<:<<:<<:<<:---------------.[-]<<:<<:<<:<<:-----------.[-]<<:<<:<<:+++++++++.[-]<<:<<:<<:<<:------------.[-]<<:++++++++++++++.[-]-+]]
n=arg[1] or #x00 IF=string _=print EXIT=os.exit I='not prime'
for i=2,n-1 do

    if IF.find('b0ss',n%i) then _(I)EXIT() end

end
print(I:sub(5))

Not a very effective way of hiding the message..

@nbubis How so?

Well, just by looking at the code I see "boss" and "I quit" :)

@nbubis MISDIRECTION, MY GOOD MAN! Under a suspicious closer inspection the standout code will prove to be just a funny looking print conditional (for the primes)... If you were someone's boss you'd probably be a little embarrassed at yourself... And then leave it at that, not checking further. It's in the BF code. I can't thank you enough for noticing and commenting on it, rbubis.

I like the submission, but I believe it's invalid. You can't use "quit" in the code. Although OP didn't say anything about case sensitivity, mh..

I'm an idiot. I wondered why I first put EXIT. Now I remember. Thanks.

05AB1E/Jelly, 28 bytes
Not one, but TWO golfing languages!
p,“ßṙ¬kʂUƭ_eµ$ⱮgkṪḞSėdȦṬSN€»

Explanation in 05AB1E:
p                                      Primality check
 ,                                     Print out; disable implicit output
  “ßṙ¬kʂUƭ_eµ$ⱮgkṪḞSėdȦṬSN€»           Push some random weird string; implicit output disabled

Explanation in Jelly:
p,                                     Doesn't matter; I have no idea what this does in Jelly
  “ßṙ¬kʂUƭ_eµ$ⱮgkṪḞSėdȦṬSN€»           Push the compressed string for "If the boss finds this, I quit."

Try it online! (Jelly)
Try it online! (05AB1E)

C# - 288
Certainly not the shortest, but it might pass by many bosses:
 int i; string t = "prime"; var test = ""; int[] tests = { 8, 8, 8, 8, 8, 8, 8, 8, 8, 73, 102, 32, 116, 104, 101, 32, 98, 111, 115, 115, 32, 102, 105, 110, 100, 115, 32, 116, 104, 105, 115, 44, 32, 73, 32, 113, 117, 105, 116, 46 }; foreach (int ts in tests) { test = test + (char)ts; t = test; } for (i = 2; i <= p / 2; i++) { if ((p % i) == 0)return "not " + t; } return t;

A readable version:
            int i;
            string t = "prime";
            var test = "";
            //tests for speed below
            int[] tests = { 8, 8, 8, 8, 8, 8, 8, 8, 8, 73, 102, 32, 116, 104, 101, 32,
            98, 111, 115, 115, 32, 102, 105, 110, 100, 115, 32, 116, 104, 105, 115, 44,
            32, 73, 32, 113, 117, 105, 116, 46 };

            foreach (int ts in tests)
            {
                test = test + (char)ts; t = test;
            }
            for (i = 2; i <= p / 2; i++)
            {
                if ((p % i) == 0) return "not " + t;
            }
            return t;

Is it a Polyglot though?

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Growing Manhattan Ameobas
An ***ameoba graph**** is a type of tree whose nodes all have values from 0 to some non-negative integer N, and any particular node with value x < N connects to x+1 distinct nodes with values x+1.
Ameoba graph for N = 3: (Denoted A3)

Note that the 2's are not allowed to share any of the 3's; exactly three 3's must "belong" to each 2.
Challenge
Your task is to inductively "grow" these ameoba graphs in a 2-dimensional grid by greedily minimizing the Manhattan distance between nodes:

Base case: A0 is simply the graph 0.
Inductive step: AN+1 is generated by iteratively placing the new N+1 valued nodes as close as possible to the N values nodes in the existing AN structure. (It can only be as close as possible since the closest spots may already be filled.)

For the inductive step the general procedure you must follow is:
for each existing node P with value N:
    for each new N+1 valued node Q you need to connect to P: //this loops N+1 times
        find the set of vacant spots that are minimally distant from P //by Manhattan distance
        place Q in any of these vacant spots

(A different procedure with indistinguishable output is fine.)
Growth example for A4:
A0 is always the same:

0

For A1 I happen to put the 1 to the right of the 0 (it has to go on one of the 4 open sides):

01

For A2 I happen to put the two 2's above and to the right of the 1:

 2
012

For A3 I find that one of the six 3's I must place cannot be directly next to a 2, so I put in one of the next closest places:

 3
323
0123
  33 <-- this 3 is distance two away from its 2

The process continues in A4. Note that I'm iterating over each 3 and placing four 4's next to it or as close as possible, then moving to the next 3 (the order of 3's does not matter):

 444
443444
4323444
4012344
 44334
  4444
   44

Always keep in mind that nodes cannot be "shared".

Program
The program you write must take in a number from 0 to 8 (inclusive) and output a valid ameoba graph of it, using the inductive growth pattern explained above.
What happens beyond 8 does not matter.
(A8 contains 46234 nodes which is pushing it. Anything beyond A8 would be too far. Thanks to Martin Büttner for noticing this.)
The input should come from stdin or the command line and output should go to stdout or a file.
Examples (taken directly from above)
Input: 0
Output:

0

Input: 1
Output:

01

Input: 2
Output:

 2
012

Input: 3
Output:

 3
323
0123
  33

Input: 4
Output:

 444
443444
4323444
4012344
 44334
  4444
   44

* These type of graphs might already have a name. I admit I just made them up. ;)

In light of the factorial growth rate, could the question be changed from stopping at A35 to stopping at a 1 Megabyte file, or something similar? A10 is the first amoeba with over a million characters.

@MartinBüttner I've made the limit 8 which is around 50k nodes. Still a lot but hopefully manageable.

Mathematica, 353 288 285 275 bytes
n=Input[];f@_=" ";g={z={0,0}};i=f@z=0;For[r=Range,i++<n,g=Reap[(j=i;o={};For[d=0,j>0,o=Rest@o,If[o=={},o=Join@@({e={#,d-#},-e,e={d-#,-#},-e}&/@r@++d)];If[f[c=#&@@o+#]==" ",f@c=i;Sow@c;--j]])&/@g][[2,1]]];Riffle[(x=#;ToString@f@{x,#}&/@m~r~M)&/@r[m=Min@{g,0},M=Max@g],"
"]<>""

Ungolfed:
n = Input[];
f@_ = " ";
g = {z = {0, 0}};
i = f@z = 0;
For[r = Range, i++ < n,
  g = Reap[(
        j = i;
        o = {};
        For[d = 0, j > 0, o = Rest@o,
         If[o == {},

          o = Join @@ ({e = {#, d - #}, -e, e = {d - #, -#}, -e} & /@
              r@++d)
          ];
         If[f[c = # & @@ o + #] == " ",
          f@c = i;
          Sow@c;
          --j
          ]
         ]
        ) & /@ g
     ][[2, 1]]
  ];
Riffle[(
     x = #;
     ToString@f@{x, #} & /@ m~r~M
     ) & /@ r[m = Min@{g, 0},
    M = Max@g
    ], "
  "] <> ""

Here is an example output for n = 5:
      5
     5555
    555555
   5555555
  555555555
 55555555555
5555554445555
5555544444555
 5555443305555
 55554432144555
 55555443234555
  5555544344555
   555554445555
    5555555555
      5555555
       55555
       55

Input 8 takes about 4.5 minutes.
For a quick breakdown of my algorithm:
I'm using two look-up tables, f and g. The first one is just a sparse map containing the non-empty cells. The latter is a list containing all coordinate pairs for each cell-value (I think I don't even need to keep track of old ones here). I'm iterating through the coordinates in g to extend every cell from the last iteration. To do that I iterate over Manhattan distances, creating all possible vectors for each distance, and checking if the resulting cell is still empty (in which case I fill it). Repeat until enough new cells have been created.
When I'm done, I find the minimum and maximum coordinate in g and I create an appropriate grid, which is filled by looking up the cells in f. The rest is just joining everything into a single string with line breaks.

C - 309 305 301 275 bytes
Meh, too long...if only one could type #D or something instead of #define, then C would be really great. Of course -D compiler flags are possible but that seems like cheating to me, to have characters other than the ones in the source file.
Running instructions:
Be careful! The first key you press after the program starts constitutes the input. Upon a character entry other than '0' through '8', who knows what undefined things will happen.
#define F(D,O)x=*r+O d;for(c=d;h*c--;x+=D)!g[x]?g[*w++=x]=l,--h:5;
L=400;g[1<<18];n;s;*r;*w;*m;h;l;d;x;main(c){n=getch()-32;r=w=g+L*L;for(l=g[*w++=80200]=16;l++<n;)for(m=w;r<m;r++)for(d=1,h=l-16;h;d++){F(L+1,-)F(L-1,-L*)F(-L+1,L*)F(~L,)}for(n=L*L;--n;)putch(n%L?g[n]+32:10);}

Ungolfed (but already thinking about future golfing) version:
void exit(int);

#define L 400

#define FIND(D, X0)   x = *pread X0 d; \
                for(c = d; c--; x+=D) { \
                    if(x%L == 0 || x%L == L-1 || x/L == 0 || x/L == L-1) \
                        exit(5); \
                    if(!g[x]) { \
                        g[*pwrite++ = x] = '0' + l; \
                        if(!--children) \
                            goto pnext; \
                    } \
                }

main()
{
    int n = getch() - '0';
    //char g[3] = {};
    char g[L*L] = {};
    int plist[46324];

    int *pwrite = plist, *pread = plist;
    *pwrite++ = L/2*L + L/2;
    g[*plist] = '0';
    int factorial = 1;
    int l,  c, parents, children, d, x;
    for(l = 1; l <= n; l++) {
        for(parents = factorial; parents--; pread++) {
            children = l;
            for(d = 1; ; d++) {
                FIND(L + 1, - )
                FIND(L - 1, -L* )
                FIND(-L + 1, +L* )
                FIND(-L - 1, + )
            }
            pnext:;
        }
        factorial *= l;
    }
    int i;
    for(i = L*L; i--; )
        putch(i%L ? (g[i] ? g[i] : ' ') : '\n');
}

Edit: I realized that since I moved the declarations outside of main(), the arrays can no longer be allocated on the stack, so I am free to use memory in a profligate manner without risk of overflow.

Ruby - 296
g=[s=' ']*d=10**6
$*[g[50500]=0].to_i.times{|c|d.times{|x|g[x]==c&&(r=1;a=c;(4.times{|v|r.times{|w|g[q=x+r*(1e3*(v-1-v/2)+v%2-v/2)+w*(1e3*~0**(v/2)+~0**v)]==s&&a>~0?(g[q]=c+1;a-=1):0}};r+=1)while~0<a)}}
g=g.join.scan(/.{1000}/)
g.map{|s|s[/\d/]&&(puts s[g.map{|s|s[/\A */].size}.min..-1].rstrip)}

Slightly ungolfed.
g=[s=' ']*d=10**6 # Initialize a big 1d array as a 2d grid
$*[g[50500]=0].to_i.times{|c| # For n times
    d.times{|x| # For each index in the grid
        g[x]==c&&( # If the element at x is equal to the current growth stage, c
            r=1;   # Initial manhattan radius = 1
            a=c;   # a is number of times the ameoba must replicate
            (4.times{|v| # For each of the 4 sides of the manhattan diamond
                r.times{|w| # For each node in each side
                    # Spawn the 'c+1' ameoba's from the c ameobas...
                    # The messy formula gives the index of the space in the grid to try spawning
                    g[q=x+r*(1e3*(v-1-v/2)+v%2-v/2)+w*(1e3*~0**(v/2)+~0**v)]==s&&a>~0?(g[q]=c+1;a-=1):0
                }
            };
            r+=1 # Increase the raidus of the manhattan diamond by one
            ) while~0<a # while not enough ameoba's have been spawned
        )
    }
}
g=g.join.scan(/.{1000}/) # Join the 1d array into a huge string and slice it into rows
# Strip away the empty spaces all around the graph and print it
g.map{|s|s[/\d/]&&(puts s[g.map{|s|s[/\A */].size}.min..-1].rstrip)}

APL (Dyalog) (121)
{0::0⋄V←,⍳⍴Z←' '⍴⍨2/M←⌈4×.5*⍨3÷⍨+/!⍳⍵⋄Z[G;G←⌈M÷2]←'0'⋄Z⊣{⍵∘{⍵∘{+((⊃F[⍋+/¨|(F←V/⍨,Z=' ')-⊂⍺])⌷Z)←⍕⍵}¨⍺/⍺}¨V/⍨,Z=⍕⍵-1}¨⍳⍵}⎕

Performance characteristics: it's O(n!). On my system, up to n=5 it's instantaneous; n=6 takes a second, n=7 takes a minute and n=8 takes an hour.
Non-golfed version
Test:
      {0::0⋄V←,⍳⍴Z←' '⍴⍨2/M←⌈4×.5*⍨3÷⍨+/!⍳⍵⋄Z[G;G←⌈M÷2]←'0'⋄Z⊣{⍵∘{⍵∘{+((⊃F[⍋+/¨|(F←V/⍨,Z=' ')-⊂⍺])⌷Z)←⍕⍵}¨⍺/⍺}¨V/⍨,Z=⍕⍵-1}¨⍳⍵}⎕
⎕:
      5

           5555
          555555
         55555555
        5555445555
       555544445555
      55554433445555
     5555444323445555
    5555544321455555
     555554430455555
     555555444555555
       555555555555
        5555555555
         55555555
          55555
           555

Explanation:

{...}⎕: read a line from the keyboard, evaluate it, and pass the result to the function.
0::0: if the other code raises an error, return a single 0. This is because the math fails when trying to calculate the size for a graph with 0 nodes, which happens to be the case when the output should be 0. (The previous version had ⍵=0:0, (if the input is 0 return 0 otherwise make the graph), but 0::0 (just try it and return 0 if it fails) is shorter.)
M←⌈4×.5*⍨3÷⍨+/!⍳⍵: assuming the output is a rough circle (this works), sum the factorials from 1 to ⍵ (= area of output), divide by 3 (close enough to pi), take the square root (giving radius of output), multiply by 4, and take the ceiling. This gives twice the diameter of the circle, so the output fits with room to spare. Store this in M.
V←,⍳⍴Z←' '⍴⍨2/M: make an M-by-M matrix of spaces and store it in Z. This will hold the output. Store a list of the coordinates of all elements in V.
Z[G;G←⌈M÷2]←'0': set the middle element of Z to 0.
Z⊢{...}¨⍳⍵: return Z, after applying the following function to the numbers 1 to ⍵:

⍵∘{...}V/,Z=⍕⍵-1: for each element in Z with the value of the previous node:

⍵∘{...}⍺/⍺: for the current node, N times,

⊃F[⍋+/¨|(F←V/⍨,Z=' ')-⊂⍺]: get the free space closest to the current node,
(...⌷Z)←⍕⍵: and set that space in Z to the value of the current node.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Life can be colorful!
Each cell in a life-like cellular automaton only needs one bit to represent it since it can only be alive or dead. That means there are only two colors; pretty boring.
Normal images have 24 bits per pixel (8 in each of R G B). This means in a normal image with pixels as cells you could simulate 24 life-like games at once!
Challenge
Your task is to write a program that will apply one generation of the rules of a life-like cellular automaton to a 24-bit depth image (in any well known format you like), and output the resulting image.
Each of the 24 layers will use the same life-like ruleset, strictly within it's own layer. The 24 layers do not interact with each other.
Also

Zeros are dead cells and ones are live cells.
Boundary conditions are periodic (forming a torus).
Any image dimensions should work.

Input/Output
Your program needs to take in 3 arguments, via stdin or command line (or your language's closest equivalent):

The name of the input image file.
A string of the digits 0 to 8 in increasing order that denotes when new cells are born:

If the digit d is in the string then dead cells come alive when they have d living neighbors.
Example: 3 is normal Life - Dead cells with exactly 3 living neighbors come to life.

A string of the digits 0 to 8 in increasing order that denotes when existing cells survive:

If the digit d is in the string then living cells with d living neighbors survive to the next generation, otherwise they die.
Example: 23 is normal Life - Only cells with exactly 2 or 3 neighbors survive to the next round.

Note that the Moore neighborhood is always used. Read this or this for more info on what precisely defines a life-like automaton and many interesting rulesets.
The 1-generation-later output image should either be displayed or saved as out.png (or bmp or whatever).
Submission
The shortest code in bytes wins.
You are required to include at least one test image and its three immediate subsequent generations for some non-trivial ruleset. Use your avatar and the normal Life rules if you can't think of anything better.
If you like you may use this Gosper Glider Gun where the only living bits are in the green 128 layer (it's only sure to work in normal Life):

Posting interesting sequences or even animations is highly encouraged.

I think it is a duplicate - the only new parts are reading in from another file format and splitting the layers - both are basic and no challenge by themselves.

@Howard But aren't you interested in seeing the images?

If you want somewhere to post pretty pictures, you could try Tumblr, Instagram, DeviantArt, ...

@PeterTaylor It seems a number of people wanted a common place to post their pretty pictures (not to mention code). God forbid we let them...

Yeah. PPCG.SE is a place of pain and agony, not fun and pretty images. If he makes the bonus idea a requirement, then surely the question must be original enough?

@Flonk I could do that if necessary. I'd prefer not though. With the layers it would be easy and fun to identify common Life structures. The 3D wont look familiar.

@Flonk, 3D Life has been done too.

@StandardToaster The upvotes don't necessarily mean that people disagree with Peter. I upvoted and would have close voted, too. Your idea is good (which is why it deserves an upvote) but that doesn't change the fact that it's too similar to an existing challenge and hence should be closed as a duplicate. There might even be a challenge in there somewhere if you can find an interesting CA that hasn't been done before.

@Martin Upvoting duplicate questions is a bad idea, because it encourages to post more questions that are similar into already existing-one.

@MartinBüttner Why close it precisely? I know it is a near-duplicate but so what? Surely the community's clear interest overpowers the rule. Isn't this site about enjoying programming, not the strict application of bureaucracy??

@PeterTaylor I have edited the question so it is no longer a duplicate. Please reopen it.

The community's clear interest is that programs not be copy-pasted with minor changes from answers to other questions. This site does not operate on the basis of "I think it might be fun, so it's ok". That's 4chan.

@PeterTaylor "The community's clear interest is that programs not be copy-pasted with minor changes from answers to other questions." That is not all all clear to me. I think by definition the community's interest is in what they upvote. Is having two similar pieces of code on this site really some unfathomable atrocity? Either way, I have clearly edited my question such that is is not a duplicate, so I see no reason why you shouldn't rescind your close-vote. (Both being actions which I believe do operate within the basis of this site.)

If you want to argue in favour of allowing duplicates, the place to do so is http://meta.codegolf.stackexchange.com . In my opinion the change you've made is so trivial that it is still a duplicate.

@PeterTaylor I made a meta post in favor of allowing duplicates (though I have no stake in this particular question). Let's continue this discussion there: http://meta.codegolf.stackexchange.com/a/2108/20260

@Howard I don't think this counts as a duplicate anymore. Surely if http://codegolf.stackexchange.com/questions/34505/simulate-rule-110 and http://codegolf.stackexchange.com/questions/4370/simulate-any-1d-cellular-automaton?rq=1 can coexist then this is not a duplicate at all.

You don't have a java answer yet! I'll give you one this afternoon.

Should we assume the cells outside the image bounds are all black?

MATLAB: 275
My favorite of the parameters I tried is 45678, 568 which following a gradual disintegration results in a sky of twinkling stars.
This image depicts, "the disintegration of the persistence of memory."

Ungolfed gif-producing code (accepts PNG without extension):
B = input('B', 's') - 48;
S = input('S', 's') - 48;
f0 = input('file: ', 's');
frames = 60;

f = sprintf('%s.png',f0);
fout = sprintf('%s.gif',f0);
first = 1;
img = imread(f);
for i = 1:60
    out = img * 0;
    [r, c, turd] = size(img);
    for b=0:7
        bimg = ~~bitand(img,2^b);
        pimg = [bimg,bimg,bimg;bimg,bimg,bimg;bimg,bimg,bimg];
        fun = @(ro,co) pimg(r+ro:r+r+ro-1,c+co:c+c+co-1,:);
        sum = fun(0,0)+fun(0,1)+fun(0,2)+fun(1,0)+fun(1,2)+fun(2,0)+fun(2,1)+fun(2,2);
        bnew = uint8(bimg & ismember(sum,S) | ~bimg & ismember(sum, B));
        out = out + 2^b * bnew;
    end
    %imwrite(out,'out.png');
       if first
           [img1,img2] = rgb2ind(img,256);
           imwrite(img1,img2,fout,'gif','Loop',Inf);
          imwrite(img1,img2,fout,'gif','WriteMode','append');
           first = 0;
       end
       img = out;
       [img1,img2] = rgb2ind(img,256);
       imwrite(img1,img2,fout,'gif','WriteMode','append');%,'DelayTime', 2*delay);
end

Golfed code that accepts a full filename (which can be GIF, JPEG, and perhaps other stuff) and writes to out.png:
I=@()input('','s');B=I();S=I();i=imread(I());o=0;[r,c,t]=size(i);for b=0:7
g=~~bitand(i,2^b);p=repmat(g,3);F=@(z,Z)p(r+z:r+r+z-1,c+Z:c+c+Z-1,:);M=@(A)ismember(F(0,0)+F(0,1)+F(0,2)+F(1,0)+F(1,2)+F(2,0)+F(2,1)+F(2,2),A-48);o=o+2^b*uint8(g&M(S)|~g&M(B));end
imwrite(o,'out.png')

A previously discovered fact is that parameters 12, 1 can be used to generate a Sierpinski carpet-like fractal. Here is one with a randomly placed seed point in each bit:

Mathematica, 359
i=InputString;f=Transpose;b=(p=FromDigits/@Characters@#&)@i[];s=p@i[];Map[FromDigits[#,2]&/@#~ArrayReshape~{3,8}&,f[(g=#;{#,Total[g~RotateRight~#&/@Drop[Join@@Table[{i,j},{i,-1,1},{j,-1,1}],{5}],1]}~f~{3,1,2}/.{l_,n_}:>Boole[l<1&&!b~FreeQ~n||l>0&&!s~FreeQ~n])&/@Apply[Join,IntegerDigits[ImageData[Import@i[],y="byte"],2,8],{2}]~f~{2,3,1},{3,1,2}],{2}]~Image~y

I'm taking input from string prompts in the order (1) birth rules, (2) survival rules, (3) file name, and I'm displaying the result right in Mathematica.
This should be able to deal with most popular formats, as long as the file actually has 24-bit depth.
Here is a somewhat ungolfed version:
i = InputString;
f = Transpose;
b = (p = FromDigits /@ Characters@# &)@i[];
s = p@i[];
Map[
  FromDigits[#,2] & /@ #~ArrayReshape~{3, 8} &,
  f[
   (
      g = #;
      {#,
         Total[g~RotateRight~# & /@
           Drop[Join @@ Table[{i, j}, {i, -1, 1}, {j, -1, 1}], {5}],
          1]}~f~{3, 1, 2} /. {l_, n_} :>
        Boole[l < 1 && ! b~FreeQ~n || l > 0 && ! s~FreeQ~n]
      ) & /@
    Apply[Join,
      IntegerDigits[ImageData[Import@i[], y = "byte"], 2, 8], {2}]~
     f~{2, 3, 1},
   {3, 1, 2}
   ],
  {2}
  ]~Image~y

Here are two examples using Rainbolt's avatar:

20 generations using the standard Game of Life [3,23]:

20 generations using [456,34567]:

And here is a GIF of the first 200 generations of the latter rule. The GIF skips every third frame, because I couldn't compress it below 2MB otherwise:

what an interesting rule

Python 2, 427
For those who don't have Mathematica ;)
import Image as I
t=raw_input
r=range
A=I.open(t())
G=map(int,t())
S=map(int,t())
w,h=A.size
B=I.new('RGB',(w,h))
A=[[map(int,("{:08b}"*3).format(*A.load()[x,y]))for y in r(h)]for x in r(w)]
for x in r(w):
 for y in r(h):
  p=''
  for i in r(24):
    c=A[x][y][i]
    n=sum(A[(x+k-1)%w][(y+j-1)%h][i]for j in r(3)for k in r(3))-c
    p+=str(~~[n in G,n in S][c])
  B.load()[x,y]=tuple(int(p[i*8:i*8+8],2)for i in r(3))
B.save('out.bmp')

It prompts for the filename, then the birth cases, then the survival cases. So for normal life rules you might input test.bmp, then 3, then 23 (no quotes or anything needed).
I used string formatting to index into and recombine the color bits, though I fear that's probably not optimal.
Note that's it's pretty slow.
Example
High life and great art mix right? (Rule 36 / 23.)

Original / Generation 1

Generation 2 / Generation 3

Java, 1085 bytes
import java.awt.image.*;import java.io.*;import javax.imageio.*;class F{static int n(boolean[][][]a,int x,int y,int z){int k=0;for(X=Math.max(x-1,0);X<Math.min(x+2,w);X++)for(Y=Math.max(y-1,0);Y<Math.min(y+2,h);Y++)if(a[X][Y][z])k++;return k-(a[x][y][z]?1:0);}static int p(String k){return Integer.parseInt(k,2);}static int w,h,x,y,z,X,Y;public static void main(String[]a)throws Exception{BufferedImage i=ImageIO.read(new File(a[0]));w=i.getWidth();h=i.getHeight();boolean[][][]G=new boolean[w][h][24];for(x=0;x<w;x++)for(y=0;y<h;y++){String k="".format("%24s",Integer.toBinaryString(0xFFFFFF&i.getRGB(x,y)));for(z=0;z<24;z++){G[x][y][z]=k.charAt(z)>48;}}for(x=0;x<w;x++)for(y=0;y<h;y++){String r="",g="",b="",k;for(z=0;z<8;){k=""+n(G,x,y,z);r+=(-1!=(G[x][y][z++]?a[1].indexOf(k):a[2].indexOf(k)))?1:0;}for(;z<16;){k=""+n(G,x,y,z);g+=(-1!=(G[x][y][z++]?a[1].indexOf(k):a[2].indexOf(k)))?1:0;}for(;z<24;){k=""+n(G,x,y,z);b+=(-1!=(G[x][y][z++]?a[1].indexOf(k):a[2].indexOf(k)))?1:0;}i.setRGB(x,y,new java.awt.Color(p(r),p(g),p(b)).getRGB());}ImageIO.write(i,"png",new File("out.png"));}}

Examples (rule 368/245):
Gen 0:

Gen 1:

Gen 2:

Gen 3:

Gen 4: