Solution of Fermat's Equation z1^n + z2^n = 1
(c) 1990, Andrew J. Hanson, Indiana University

Implementation assisted by Stewart Dickson and Phillip Boyland
Notes and alternate viewpoints by Andre Kuzniarek

This is the initial set-up:

MakePolygons[vl_List] :=
    Block[{l = vl,
           l1 = Map[RotateLeft, vl],
           mesh},
        mesh = {l, RotateLeft[l], RotateLeft[l1], l1};
        mesh = Map[Drop[#, -1]&, mesh, {1}];
        mesh = Map[Drop[#, -1]&, mesh, {2}];
        Polygon /@ Transpose[ Map[Flatten[#, 1]&, mesh] ]
    ]

u1[a_,b_] := .5 (E^(a + I*b) + E^(- a - I*b))

u2[a_,b_] := .5 (E^(a + I*b) - E^(- a - I*b))

z1k[a_,b_,n_,k_] := E^(k*2*Pi*I/n)*u1[a,b]^(2.0/n)

z2k[a_,b_,n_,k_] := E^(k*2*Pi*I/n)*u2[a,b]^(2.0/n)

The following series of inputs are identical except for differing values for n
and differing imaging resolutions. Choose only one of the following 6 inputs to 
evaluate for any given image or series of images. n=3 creates the simplest image, 
n=4 and n=5 are some of the simplest. Anything beyond n=6 will no doubt 
overwhelm your machine:

n=3; alpha = 0.25 Pi;
Do[ Do[ surface[k1+1,k2+1] =
      MakePolygons[Table[
        N[{Re[z1k[a,b,n,k1]], Re[z2k[a,b,n,k2]],
             Cos[alpha]*Im[z1k[a,b,n,k1]] + Sin[alpha]*Im[z2k[a,b,n,k2]]}],
         {a,-1.0,1.0,0.2}, {b,0, .5 Pi, .05 Pi}]],
    {k2,0, n - 1}],
  {k1,0, n - 1}]

n=4; alpha = 0.25 Pi;
Do[ Do[ surface[k1+1,k2+1] =
      MakePolygons[Table[
        N[{Re[z1k[a,b,n,k1]], Re[z2k[a,b,n,k2]],
             Cos[alpha]*Im[z1k[a,b,n,k1]] + Sin[alpha]*Im[z2k[a,b,n,k2]]}],
         {a,-1.0,1.0,0.2}, {b,0, .5 Pi, .05 Pi}]],
    {k2,0, n - 1}],
  {k1,0, n - 1}]

n=5; alpha = 0.25 Pi;
Do[ Do[ surface[k1+1,k2+1] =
      MakePolygons[Table[
        N[{Re[z1k[a,b,n,k1]], Re[z2k[a,b,n,k2]],
             Cos[alpha]*Im[z1k[a,b,n,k1]] + Sin[alpha]*Im[z2k[a,b,n,k2]]}],
         {a,-1.0,1.0,0.2}, {b,0, .5 Pi, .05 Pi}]],
    {k2,0, n - 1}],
  {k1,0, n - 1}]

n=3; alpha = 0.25 Pi;
Do[ Do[ surface[k1+1,k2+1] =
      MakePolygons[Table[
        N[{Re[z1k[a,b,n,k1]], Re[z2k[a,b,n,k2]],
             Cos[alpha]*Im[z1k[a,b,n,k1]] + Sin[alpha]*Im[z2k[a,b,n,k2]]}],
         {a,-1.0,1.0,0.33333}, {b,0, .5 Pi, .1 Pi}]],
    {k2,0, n - 1}],
  {k1,0, n - 1}]

n=4; alpha = 0.25 Pi;
Do[ Do[ surface[k1+1,k2+1] =
      MakePolygons[Table[
        N[{Re[z1k[a,b,n,k1]], Re[z2k[a,b,n,k2]],
             Cos[alpha]*Im[z1k[a,b,n,k1]] + Sin[alpha]*Im[z2k[a,b,n,k2]]}],
         {a,-1.0,1.0,0.33333}, {b,0, .5 Pi, .1 Pi}]],
    {k2,0, n - 1}],
  {k1,0, n - 1}]

n=5; alpha = 0.25 Pi;
Do[ Do[ surface[k1+1,k2+1] =
      MakePolygons[Table[
        N[{Re[z1k[a,b,n,k1]], Re[z2k[a,b,n,k2]],
             Cos[alpha]*Im[z1k[a,b,n,k1]] + Sin[alpha]*Im[z2k[a,b,n,k2]]}],
         {a,-1.0,1.0,0.33333}, {b,0, .5 Pi, .1 Pi}]],
    {k2,0, n - 1}],
  {k1,0, n - 1}]

This creates the Fermat object and the default viewpoint:

Fermat = Show[Graphics3D[Table[surface[k1, k2], {k1, 1, n}, {k2, 1, n}]],
				Boxed->False]

This creates the same Fermat object with a black background:

Show[Fermat, Background->RGBColor[0, 0, 0]]

This is Stewart Dickson's favorite viewpoint, with n=3:

Show[Fermat, ViewPoint->{1.1771, 2.2947, -2.1905}]

Show[Fermat, ViewPoint->{1.1771, 2.2947, -2.1905},
				Background->RGBColor[0, 0, 0]]

This is Andre Kuzniarek's favorite viewpoint, with n=4:

Show[Fermat, ViewPoint->{-0.170, 0.170, 1.643}]

Show[Fermat, ViewPoint->{-0.170, 0.170, 1.643},
				Background->RGBColor[0, 0, 0]]

Here are some more viewpoints:

Show[Fermat, ViewPoint->{1.0812, -0.9385, -3.0659}]

Show[Fermat, ViewPoint->{1.0812, -0.9385, -3.0659},
				Background->RGBColor[0, 0, 0]]

Show[Fermat, ViewPoint->{2, 0.000, 0.934}]

Show[Fermat, ViewPoint->{2, 0.000, 0.934},
				Background->RGBColor[0, 0, 0]]

Explanatory text:

The picture shows a projection from four-dimensional space of the so-called projective 
variety that represents all possible solutions of the equation x^n + y^n == z^n 
for n = [depends on picture]. What Fermat's Last Theorem states is that none of 
these solutions can correspond to integer values of x, y and z.]

Credits: Andrew Hanson / Stewart Dickson / Wolfram Research