Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

binomial._eval_Mod problems for composite modulus #19082

Open
smichr opened this issue Apr 6, 2020 · 1 comment · May be fixed by #18960
Open

binomial._eval_Mod problems for composite modulus #19082

smichr opened this issue Apr 6, 2020 · 1 comment · May be fixed by #18960

Comments

@smichr
Copy link
Member

smichr commented Apr 6, 2020

>>> binomial(5, 3)
10
>>> [binomial(5,3)%i for i in range(9,18)]
[1, 0, 10, 10, 10, 10, 10, 10, 10]
>>> [binomial(5, 3, evaluate=False) % i for i in range(9,18)]
[3, 0, 10, 6, 10, 2, 0, 14, 10]
>>> list(range(9,18))
[9, 10, 11, 12, 13, 14, 15, 16, 17]

It appears to only be correct when the binomial value equals the modulus or when the modulus is prime.

@smichr
Copy link
Member Author

smichr commented Apr 6, 2020

This can be fixed by making sure that min(k, n - k) is selected when n > 0 and k > 0 and n - k > 0. I will add this to #18960.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants