Create ModularExponentiation.java#5091
Create ModularExponentiation.java#5091lulunac27a wants to merge 7 commits intoTheAlgorithms:masterfrom
Conversation
Add modular exponentiation in Java
There was a problem hiding this comment.
Please:
- add proper junit tests,
- your code does not work for negative
y, - reformat the code,
- please apply your function in other places, where this function is needed, e.g.
I also think that this could be a generic, to handle ints and longs.
Further more, what do you think about renaming it to modPow - this seems to be a more standard name in this context.
|
Add tests and code if y (power) is 0, return 1 |
|
I think you also want to throw an exception for |
|
@lulunac27a please fix all of the errors from the CI and please have a look at my previous comment. |
|
Fixed errors by formatting code and changing function name to |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution! |
|
Please reopen this pull request once you have made the required changes. If you need help, feel free to ask in our Discord server or ping one of the maintainers here. Thank you for your contribution! |
Add modular exponentiation in Java
clang-format -i --style=file path/to/your/file.java