我需要計算這樣的:2894135^3787313 MOD 4028033我簡單的計算與Bigintegers不工作
正如你可以看到下面我試圖使用的BigInteger,因爲我真的有龐大的數字。
import java.lang.Math;
import java.util.Scanner;
public class BigInteger extends Number implements Comparable<BigInteger>
{
public static void main(String[] args)
{
BigInteger result=new BigInteger(Math.pow(2894135,3787313) % 4028033);
System.out.println(result);
}
}
錯誤:
/tmp/java_Wcf144/BigInteger.java:19: error: BigInteger is not abstract and does not override abstract method doubleValue() in Number public class BigInteger extends Number implements Comparable ^/tmp/java_Wcf144/BigInteger.java:24: error: constructor BigInteger in class BigInteger cannot be applied to given types;
BigInteger result=new BigInteger(Math.pow(2894135,3787313) % 4028033); ^ required: no arguments found: double reason: actual and formal argument lists differ in length 2 errors
類重命名爲'BigInteger' – Reimeus
除了別的其它別的東西,你想要做的所有算術*第一個*,然後轉換*結果*到'BigInteger'。這是行不通的。你應該在'BigInteger'中做所有算術*。是的,正如Reimeus所說,你真的不想將自己的類聲明爲BigInteger ... –
但*不要*將它重命名爲Biginteger(如在標題中)。 –