public static void IID() { BigNum n = new BigNum(55687); BigNum i = new BigNum(1L); int count = 0; BigNum y = new BigNum(41008L); BigNum a = new BigNum(23425L); BigNum x = MathOps.Power(y, a, n); Console.WriteLine(x.DecimalValue); //while (i<=n) //{ // BigNum gcd = new BigNum(); // MathOps.ExtendedGCD(i, n, new BigNum(), new BigNum(), gcd); // if (!gcd.CompNumWithoutPrint(GlobalVariables.one)) // { // count++; // Console.WriteLine(i.DecimalValue); // } // i.AddNum(GlobalVariables.one); //} Console.WriteLine(count); }
public static void IIA() { Console.WriteLine("I."); Console.WriteLine("Calculating 1233456897 ^ 8001 mod 1783369431"); BigNum num = new BigNum(1233456897); BigNum power = new BigNum(8001); BigNum mod = new BigNum(1783369431); BigNum result = new BigNum(); result = MathOps.Power(num, power, mod); Console.WriteLine(result.DecimalValue); Console.WriteLine(); }
public static void M() { Console.WriteLine("(M) Using Power method."); Console.WriteLine("Calculating 30^14 mod 7 = 4."); BigNum x = new BigNum(30); BigNum power = new BigNum(14); BigNum mod = new BigNum(7); Console.WriteLine(MathOps.Power(x, power, mod).DecimalValue); Console.WriteLine("Calculating 130^27 mod 41 = 24."); BigNum x2 = new BigNum(130); BigNum power2 = new BigNum(27); BigNum mod2 = new BigNum(41); Console.WriteLine(MathOps.Power(x2, power2, mod2).DecimalValue); Console.WriteLine(); }