Ask Your Question

Revision history [back]

I did some code investigation and found the following explanation. The changes were introduced in trac ticket 23338, and you can see in the changes made on the function, that before, your k was tested to be an integer (see the isinstance(arg1, integer_types + (Integer,)) tests), this is why you get an error since your k is a rational, not an integer:

sage: k
sage: k.parent()
Rational Field
sage: from six import integer_types
sage: isinstance(k, integer_types + (Integer,))

In the recent implementation, your k is transformed into an integer, see k = Integer(arg), this is why your code works on recent versions of Sage.

So, though i encourage you to upgrade your Sage installation, you can also transform your k into an integer:

sage: k = ZZ(n*(n-1)/2)


sage: k = Integer(n*(n-1)/2)