Steven D'Aprano <[email protected]> added the comment:
> should the function be expanded to calculate for negative
> n or is the function expected to work only in combination sense?
If this were my design, I would offer both but in separate functions:
def comb(n, k):
if n < 0: raise ValueError
return bincoeff(n, k)
def bincoeff(n, k):
if n < 0:
return (-1)**k * bincoeff(n+k+1, k)
else:
# implementation here...
I believe we agreed earlier that supporting non-integers was not
necessary.
Are you also providing a perm(n, k) function?
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue35431>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com