It's fairly easy to see by running it that the program generates
prime numbers.  It does so very slowly, and in an unusual manner.

The $n string encodes a series of fractions (by adding 31 to make
them printable):

17  78  19  23  29  77  95  77   1  11  13  15  15  55
--  --  --  --  --  --  --  --  --  --  --  --  --  --  
91  85  51  38  33  29  23  19  17  13  11  14   2   1

The main program performs the following loop:

$o = 2;

while(1)
{
   foreach $f (fractions)
   {
      if $o * $f is an integer 
      {
         $o = $o * $f;
	 $p = PowerOfTwo($o);
	 if $p 
	 {
	    print $p;
	 }
	 continue;
       }
   }
}

The PowerOfTwo function checks to see if its input is a power of 
two, and returns log base 2 of its input.

The actual code needs arbitrarily large integers to represent $o, so
it uses the u() and d() functions for multiplication and division.

They're generated by two eval calls, so that they can share the same
setup code.  After the evals, they look like this:

sub u
{
   $a=shift;
   $g=$h=$i=0;
   @c=map{
      $g+=$_*$a;
      $b=$g%$B;
      $g/=$B;
      $b;
    } @_;
   !$g||push@c,$g;
   @c;
}

sub d{
   $a=shift;
   $g=$h=$i=0;
   @c=reverse map{
      $h=($_+$g*$B)/$a;
      $g=($_+$g*$B)-$h*$a;
      $h;
   } reverse @_;
   @c[$#c]!=0 || pop @c;
   ($g,@c);
}

In the case of the d() subroutine, both the remainder and the quotient 
are returned.  $B is the base in which the large numbers are encoded.
I chose 65521 since it's a nice prime, but there's really no need for
it to be prime.

These magic fractions work by encoding a state machine which tests for 
primality.  It relies on the fact that all integers have a unique
prime factorization.  The $o variable actually contains all of the
"registers" in the state machine:

$o = 2^A * 3^B * 5^C * 7^D ...

A, B, C, D, etc represent the values of the registers.  Each fraction
is an instruction.  For example:

   78     2 * 3 * 13
   --  =  ----------
   85       5 * 17

This instruction says:

   if ($v5 && $v17)
   {

	$v5--;		# divide by 85
	$v17--;

	$v2++;		# multiply by 78
	$v3++;
	$v13++;
   }

The entire set of fractions encodes an algorithm that tests for
primality by repeated trial division.  It does the division by
repeated subtraction, and the subtraction by repeated decrementing.

This technique was invented by John Conway, the mathematician famous
in computer circles for inventing the game of life.

Just to add an additional layer of obfuscation, the program is
formatted to look like the Greek symbol Pi, which has nothing to do
with what the program actually does.
