// Show that the product of two multipliers mod a number is the product of // each multiplier mod the number. // Example: 'modulo 4 5 7' // 4 * 5 mod 7 = 6 // (4 mod 7 * 5 mod 7) mod 7 = 6 #include #include "bigint.h" using namespace std; int main (int argc, char **argv) { if (argc != 4) { cout << "Usage: " << argv[0] << " \n"; exit(0); } BigInt num1(atoi(argv[1])); BigInt num2(atoi(argv[2])); BigInt modulus(atoi(argv[3])); cout << num1 << " * " << num2 << " mod " << modulus << " = " << ((num1*num2) % modulus) << "\n"; cout << "(" << num1 << " mod " << modulus << " * " << num2 << " mod " << modulus << ") mod " << modulus << " = " << (((num1 % modulus)*(num2 % modulus)) % modulus) << "\n"; }