C-Plus-Plus
C-Plus-Plus copied to clipboard
fix: make interface of `NCRModuloP` fail-safe
Description of Change
The original implementation of NCRModuloP, has two problems:
- the member variable
facis one element too short, - the computation
math::ncr_modulo_p::NCRModuloP(100, 43).ncr(10, 3, 13)returns2, which is incorrect since10C3 = 120and120%13 = 3(note different values ofp).
This PR fixes above issues and does some minor refactoring, style improvements and adds missing test cases.
Checklist
- [x] Added description of change
- [x] Added tests and example, test must pass
- [x] Added documentation so that the program is self-explanatory and educational - Doxygen guidelines
- [x] Relevant documentation/comments is changed or added
- [x] PR title follows semantic commit guidelines
- [x] Search previous suggestions before making a new one, as yours may be a duplicate.
- [x] I acknowledge that all my contributions will be made under the project's license.
Notes:
Updates to fail-safe API of NCRModuloP
Please do not resolve unless you have instructions to do so or the changes are sufficiently discussed
@Panquesito7 could you please have a final look?
@Panquesito7, @realstealthninja could you please have a final look?
This pull request has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@Panquesito7, @realstealthninja please dont-close.