練習問題/解答例/累乗/課題1/Java
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
[[練習問題]]
import java.math.*;
public class Main {
private BigInteger pow(int a, int n) {
BigInteger res = BigInteger.ONE;
BigInteger val = BigInteger.valueOf(a);
for(int i=0; i<n; i++) {
res = res.multiply(val);
}
return res;
}
private void doIt() {
System.out.printf("%s\n", pow(2, 0));
System.out.printf("%s\n", pow(2, 1));
System.out.printf("%s\n", pow(2, 2));
System.out.printf("%s\n", pow(2, 10));
System.out.printf("%s\n", pow(2, 1024));
System.out.printf("%s\n", pow(2, 1000007)); // ...
}
public static void main(String[] args) { new Main()....
}
終了行:
[[練習問題]]
import java.math.*;
public class Main {
private BigInteger pow(int a, int n) {
BigInteger res = BigInteger.ONE;
BigInteger val = BigInteger.valueOf(a);
for(int i=0; i<n; i++) {
res = res.multiply(val);
}
return res;
}
private void doIt() {
System.out.printf("%s\n", pow(2, 0));
System.out.printf("%s\n", pow(2, 1));
System.out.printf("%s\n", pow(2, 2));
System.out.printf("%s\n", pow(2, 10));
System.out.printf("%s\n", pow(2, 1024));
System.out.printf("%s\n", pow(2, 1000007)); // ...
}
public static void main(String[] args) { new Main()....
}
ページ名: