A prime knot is:

a non-trivial knot which cannot be written as the knot sum of two non-trivial knots.

Explanation of a knot-sum: put the two knots adjacent,

enter image description here

... then draw two lines between them, to the same strand on each side, and remove the part between the lines you just drew. This composition of two knots will form a new, non-prime knot.

enter image description here

Here are all prime knots with 7 or fewer crossings (the Unknot is not prime):

enter image description here

You need to output the number of unique prime knots for a given number of crossings.

1   0
2   0
3   1
4   1
5   2
6   3
7   7
8   21
9   49
10  165
11  552
12  2176
13  9988
14  46972
15  253293
16  1388705

I don't think the values are known for inputs larger than 16, but if given such an input, your code would need to find the correct result given enough time.

OEIS - A002863


1 Answer 1


Mathematica + KnotTheory`, 13 bytes


I didn't know this built-in function existed when I commented that the package might be useful. Everyone else had an equal chance to find it, since I commented about the library. I found it in the list of Lightly Documented Features. Still, I won't accept this answer, since I want to see answers by other people.

  • 1
    \$\begingroup\$ Seeing as the documentation is very poor are you sure this works for numbers greater than 16? \$\endgroup\$
    – Wheat Wizard
    Commented Dec 22, 2016 at 16:03
  • \$\begingroup\$ @WheatWizard No, I'm not sure how to tell. It would take way too long to run to completion. Is there a way to find out how it's implemented? \$\endgroup\$
    – mbomb007
    Commented Dec 22, 2016 at 16:40
  • 1
    \$\begingroup\$ Have you tried running it? It might just return an error. I can't run mathematica right now but I would check if it stalls when you attempt to run it. \$\endgroup\$
    – Wheat Wizard
    Commented Dec 22, 2016 at 17:07
  • \$\begingroup\$ @WheatWizard I can't check either. Let me know if you try it. \$\endgroup\$
    – mbomb007
    Commented Dec 22, 2016 at 17:49
  • \$\begingroup\$ I actually looked through the source code for a bit, searching for it, but I didn't find the definition. The repository is publicly available. katlas.math.toronto.edu/svn/KnotTheory/trunk/KnotTheory \$\endgroup\$
    – mbomb007
    Commented Dec 22, 2016 at 17:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.