我必须将x和y之类的两个大数相乘,然后在不使用BigInteger
的情况下通过p找到结果的mod:
public static char[] x = {'1','1','5','7','9','2','0','8','9','2','3','7','3','1','6','1','9','5','4','2','3','5','7','0','9','8','5','0','0','8','6','8','7','9','0','7','8','5','3','2','6','9','9','8','4','6','6','5','6','4','0','5','6','4','0','3','9','4','5','7','5','8','4','0','0','7','9','0','8','8','3','3','7','6','6','4','4','7'};
public static char[] y = {'1','1','5','7','9','2','0','8','9','2','3','7','3','1','6','1','9','5','4','2','3','5','7','0','9','8','5','0','0','8','6','8','7','9','0','7','8','5','3','2','6','9','9','8','4','6','6','5','6','4','0','5','6','4','0','3','9','4','4','3','7','4','8','7','3','8','7','4','7','3','1','9','0','6','9','7','4','3'};
public static char[] p = {'1','1','5','7','9','2','0','8','9','2','3','7','3','1','6','1','9','5','4','2','3','5','7','0','9','8','5','0','0','8','6','8','7','9','0','7','8','5','3','2','6','9','9','8','4','6','6','5','6','4','0','5','6','4','0','3','9','4','5','7','5','8','4','0','0','7','9','0','8','8','3','4','6','7','1','6','6','3'};
我找到了如何乘以x和y,但我不知道如何计算两个大数的mod 任何人都可以帮助我吗?
答案 0 :(得分:0)
你能比较x和y吗?
如果你可以比较它们,你可以很容易地实现mod算法。
伪代码
function mod(a , b) {
while( a > b ) { a = a - b; }
return a;
}
我不懂java,这只是算法的伪代码 但是如果你已经实现了减法和比较函数,你可以在这里使用它们。