回答編集履歴
5
コメント追加
answer
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
```Java
|
6
6
|
public class Main{
|
7
7
|
public static void main(String[] args){
|
8
|
-
int maxValue = 2147483647;
|
8
|
+
int maxValue = 2147483647; //メルセンヌ素数の1つ。intの最大値。
|
9
9
|
// 値が大きすぎるため、for文をコメントアウト
|
10
10
|
//for(int testNumber=2;testNumber<=maxValue;testNumber++){
|
11
11
|
/*素数を出力する*/
|
4
コードのミス修正
answer
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
// 値が大きすぎるため、for文をコメントアウト
|
10
10
|
//for(int testNumber=2;testNumber<=maxValue;testNumber++){
|
11
11
|
/*素数を出力する*/
|
12
|
-
if(isPrimeNumber(
|
12
|
+
if(isPrimeNumber(testNumber)){
|
13
13
|
System.out.println(testNumber);
|
14
14
|
}
|
15
15
|
//}
|
3
コード修正
answer
CHANGED
@@ -5,12 +5,14 @@
|
|
5
5
|
```Java
|
6
6
|
public class Main{
|
7
7
|
public static void main(String[] args){
|
8
|
+
int maxValue = 2147483647;
|
9
|
+
// 値が大きすぎるため、for文をコメントアウト
|
8
|
-
for(int testNumber=2;testNumber<=
|
10
|
+
//for(int testNumber=2;testNumber<=maxValue;testNumber++){
|
9
11
|
/*素数を出力する*/
|
10
12
|
if(isPrimeNumber(2147483647)){
|
11
13
|
System.out.println(testNumber);
|
12
14
|
}
|
13
|
-
}
|
15
|
+
//}
|
14
16
|
}
|
15
17
|
|
16
18
|
private static boolean isPrimeNumber(int testNumber){
|
2
インデント修正
answer
CHANGED
@@ -6,11 +6,10 @@
|
|
6
6
|
public class Main{
|
7
7
|
public static void main(String[] args){
|
8
8
|
for(int testNumber=2;testNumber<=100;testNumber++){
|
9
|
-
|
10
|
-
|
9
|
+
/*素数を出力する*/
|
11
|
-
|
10
|
+
if(isPrimeNumber(2147483647)){
|
12
|
-
|
11
|
+
System.out.println(testNumber);
|
13
|
-
|
12
|
+
}
|
14
13
|
}
|
15
14
|
}
|
16
15
|
|
1
補足追記
answer
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
下記参考にしてください。
|
2
2
|
そして、実行が上手くいったら、数値を1つ増やしてみてください。
|
3
|
+
どちらも、興味深い結果になると思います。
|
3
4
|
|
4
5
|
```Java
|
5
6
|
public class Main{
|