```
/*

A program to compute how many different non-trivial links of
k-dimensional spheres there are in n-dimensional space.

See the WWW site

Permission is granted to use or modify this program for any
non-commericial use.

the author assumes no responsibility for damage or loss of property
that may result from incorrect calculations.

To contact the author:

Robert G. Scharein                email: scharein@cs.ubc.ca
Department of Computer Science    phone: (604) 822-8572 (Office, rm 249)
2366 Main Mall - Room 201                (604) 822-2218 (Imager Lab)
University of British Columbia    FAX:   (604) 822-5485
Vancouver, B.C. CANADA  V6T 1Z4   WWW:   ../various/scharein.html

*/

#include

#define INFINITE  -1
#define NON_ZERO  -2
#define UNKNOWN   -3

main (argc, argv)
int argc;
char **argv;
{
extern long order_pi ();
long n, nr1, r;
long nways, nwaysp1;
long order;

if (argc < 3) {
fprintf (stderr, "USAGE: %s  sphere-dimen space-dimen\n\n", argv );
fprintf (stderr, "       displays the number of non-trivial links of\n");
fprintf (stderr, "       two spheres of dimension  in a space\n");
fprintf (stderr, "       of dimension  in the piecewise linear\n");
fprintf (stderr, "       catagory.\n");
exit (102);
}

n = atoi (argv );
nr1 = atoi (argv );
r = nr1 - n - 1;
/*
printf ("n = %d, n / 2 + 1 = %d < r = %d <= 2 * n + 1 = %d\n",
n, n / 2 + 1, r, 2 * n + 1);
*/
if (n >= 2 && r >= n / 2 + 1 && nr1 <= 2 * n + 1)
switch (nwaysp1 = order_pi ((long) n, (long) r)) {
case INFINITE:
nways = INFINITE;
break;
case UNKNOWN:
nways = UNKNOWN;
break;
default:
nways = nwaysp1 - 1;
}
else if (n >= 1 && nr1 == n + 2)
nways = INFINITE;
else if (n >= 1 && 1 < r && r < n / 2 + 1) {
if (order_pi (n, r) > 1)
nways = NON_ZERO;
else
nways = UNKNOWN;
}
else if (n >= 1 && nr1 > 2 * n + 1)
nways = 0;
else if (n >= 1 && nr1 < n + 2 && nr1 >= n)
nways = 0;
else if (nr1 < n && n >= 1) {
fprintf (stderr, "A %d-sphere can't even be embedded in %d-space!!\n",
n, nr1);
exit (-102);
}
else {
fprintf (stderr, "Those numbers don't make sense.\n");
exit (1022);
}

switch (nways) {
case INFINITE:
printf ("Two %d-dimensional spheres link in %d-space in an infinite number of distinct ways.\n",
n, nr1);
break;
case 0:
printf ("There are no non-trivial links of two %d-dimensional spheres in %d-space.\n",
n, nr1);
break;
case NON_ZERO:
printf ("There are non-trivial links of two %d-dimensional spheres in %d-space.\n",
n, nr1);
break;
case UNKNOWN:
printf ("The number of non-trivial links of two %d-dimensional spheres in %d-space is unknown.\n",
n, nr1);
break;
case 1:
printf ("There is one non-trivial way to link two %d-dimensional spheres in %d-space.\n",
n, nr1);
break;
default:
printf ("There are %d non-trivial ways to link two %d-dimensional spheres in %d-space.\n",
nways, n, nr1);
}

}

long order_pi (nplusk, n)
long nplusk, n;
{
long k;

k = nplusk - n;

/*
printf ("k = %d\n", k);
*/
if (k < 0) return 1;

switch (k) {
case 0:
return INFINITE;
case 1:
return 2;
case 2:
return 2;
case 3:
return 24;
case 4:
return 1;
case 5:
return 1;
case 6:
return 2;
case 7:
return 240;
case 8:
return 2 * 2;
case 9:
return 2 * 2 * 2;
case 10:
return 6;
case 11:
return 504;
case 12:
return 1;
case 13:
return 3;
case 14:
return 2 * 2;
case 15:
return 480 * 2;
case 16:
return 2 * 2;
case 17:
return 2 * 2 * 2 * 2;
case 18:
return 8 * 2;
case 19:
return 264 * 2;
case 20:
return 24;
case 21:
return 2 * 2;
case 22:
return 2 * 2;
case 23:
return 65520 * 8 * 2;
case 24:
return 2 * 2;
case 25:
return 2 * 2;
case 26:
return 6 * 2;
case 27:
return 24;
case 28:
return 2;
case 29:
return 1;
case 30:
return 2;
case 31:
return 16320 * 2;
case 32:
return 2 * 2;
case 33:
return 4 * 2 * 2 * 2 * 2;
default:
return UNKNOWN;
}

}

```