|
Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
|
C++ Program for Modular Exponentiation Iteratively. More...
#include <cassert>#include <iostream>Namespaces | |
| namespace | math |
| for std::rand | |
Functions | |
| uint64_t | math::power (uint64_t a, uint64_t b, uint64_t c) |
| This function calculates a raised to exponent b under modulo c using modular exponentiation. More... | |
| static void | test () |
| int | main () |
| Main function. More... | |
C++ Program for Modular Exponentiation Iteratively.
The task is to calculate the value of an integer a raised to an integer exponent b under modulo c.
Example: (4^3) % 5 (where ^ stands for exponentiation and % for modulo) (4*4*4) % 5 (4 % 5) * ( (4*4) % 5 ) 4 * (16 % 5) 4 * 1 4 We can also verify the result as 4^3 is 64 and 64 modulo 5 is 4
| int main | ( | void | ) |
|
static |
Function for testing power function. test cases and assert statement.
void