From af3fadc80097901674383e87875d3b50fe212fbc Mon Sep 17 00:00:00 2001 From: Shri Prakash Bajpai <68155959+Shri2206@users.noreply.github.com> Date: Wed, 21 Oct 2020 16:09:50 +0530 Subject: [PATCH] Update modular_exponentiation.cpp --- math/modular_exponentiation.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/math/modular_exponentiation.cpp b/math/modular_exponentiation.cpp index 22ba7eaba..1ccd67434 100644 --- a/math/modular_exponentiation.cpp +++ b/math/modular_exponentiation.cpp @@ -2,7 +2,7 @@ * @file * @brief C++ Program for Modular Exponentiation Iteratively. * Calculate the value of an integer a raised to an integer exponent b - * under modulo c. + * under modulo c. * @note The time complexity of this approach is O(log b). * * Example: @@ -15,15 +15,20 @@ * We can also verify the result as 4^3 is 64 and 64 modulo 5 is 4 */ -#include +#include /// for io operations +/** + * @namespace math + * @brief Mathematical algorithms + */ +namespace math { /** * @brief This function calculates a raised to exponent b -* under modulo c using modular exponentiation. +* under modulo c using modular exponentiation * @param a integer base * @param b unsigned integer exponent * @param c integer modulo -* @return a raised to power b modulo c. +* @return a raised to power b modulo c */ int power(int a, unsigned int b, int c) { @@ -51,7 +56,8 @@ int power(int a, unsigned int b, int c) } return ans; -} +} +} // namespace math /** * @brief Main function @@ -65,7 +71,7 @@ int main() int m = 13; std::cout << "The value of "<