From 35d4b9f72bfbb1590f42a87bd796303034507265 Mon Sep 17 00:00:00 2001 From: CarlosZoft <62192072+CarlosZoft@users.noreply.github.com> Date: Tue, 15 Feb 2022 15:36:55 -0300 Subject: [PATCH] feat : add unsigned type for block negative number and improving description --- math/modular_inverse_simple.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/math/modular_inverse_simple.cpp b/math/modular_inverse_simple.cpp index dd2b4bc65..8b92435d7 100644 --- a/math/modular_inverse_simple.cpp +++ b/math/modular_inverse_simple.cpp @@ -10,8 +10,8 @@ * https://en.wikipedia.org/wiki/Modular_multiplicative_inverse */ -#include -#include +#include /// for assert +#include /// for IO operations /** * @brief Function imod @@ -20,9 +20,9 @@ * @param y number * @returns the modular inverse */ -int imod(int x, int y) { - int aux = 0; - int itr = 0; +uint64_t imod(uint64_t x, uint64_t y) { // positive integer expected + uint64_t aux = 0; // auxiliary variable + uint64_t itr = 0; // iteration counter do { // run the algorithm while not find the inverse aux = y * itr + 1; @@ -33,7 +33,7 @@ int imod(int x, int y) { } /** - * @brief Some test cases + * @brief self-test implementations * @returns void */ static void test() { @@ -59,5 +59,5 @@ static void test() { * @returns 0 on exit */ int main() { - test(); // run tests implementations + test(); // run self-test implementations };