Annoying comments removed that displayed strangely in my editor.
Added in timing code for testing all the problems with k,n.
The benchmarks on my computer looked like this, where the tuple is (k,n,seconds to computer):
(3, 3, 1.2874603271484375e-05)
(3, 4, 0.0007729530334472656)
(3, 5, 3.4375200271606445)
(4, 4, 1.0013580322265625e-05)
(4, 5, 0.0028030872344970703)
(4, 6, 24960.645797014236)