質問編集履歴
5
コードの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -92,9 +92,15 @@
|
|
92
92
|
|
93
93
|
|
94
94
|
|
95
|
-
if i == 0 || i == 1
|
95
|
+
if i == 0 || i == 1
|
96
96
|
|
97
97
|
puts "false"
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
elsif i == 2
|
102
|
+
|
103
|
+
puts "true"
|
98
104
|
|
99
105
|
|
100
106
|
|
@@ -125,6 +131,8 @@
|
|
125
131
|
end
|
126
132
|
|
127
133
|
end
|
134
|
+
|
135
|
+
|
128
136
|
|
129
137
|
```
|
130
138
|
|
4
コードの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -30,7 +30,7 @@
|
|
30
30
|
|
31
31
|
|
32
32
|
|
33
|
-
if i = 1 || i = 0 ||
|
33
|
+
if i = 1 || i = 0 ||
|
34
34
|
|
35
35
|
judge = 1
|
36
36
|
|
3
指摘に基づきもう一度追記しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -82,6 +82,52 @@
|
|
82
82
|
|
83
83
|
|
84
84
|
|
85
|
+
###追記2
|
86
|
+
|
87
|
+
```Ruby
|
88
|
+
|
89
|
+
puts "値を入力"
|
90
|
+
|
91
|
+
i = gets.chomp.to_i
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
if i == 0 || i == 1 || i == 2
|
96
|
+
|
97
|
+
puts "false"
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
else
|
102
|
+
|
103
|
+
(2..i - 1).each do |num|
|
104
|
+
|
105
|
+
if 0 == i % num
|
106
|
+
|
107
|
+
puts "false"
|
108
|
+
|
109
|
+
break
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
elsif num == i - 1
|
114
|
+
|
115
|
+
puts "true"
|
116
|
+
|
117
|
+
break
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
else
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
```
|
130
|
+
|
85
131
|
### 追記
|
86
132
|
|
87
133
|
```Ruby
|
2
少し改良しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -100,15 +100,17 @@
|
|
100
100
|
|
101
101
|
else
|
102
102
|
|
103
|
-
(2..i-1).each do |num|
|
103
|
+
(2..i - 1).each do |num|
|
104
104
|
|
105
|
-
|
105
|
+
if 0 == i % num
|
106
106
|
|
107
|
-
|
107
|
+
puts "false"
|
108
108
|
|
109
|
-
|
109
|
+
break
|
110
110
|
|
111
|
+
|
112
|
+
|
111
|
-
|
113
|
+
else
|
112
114
|
|
113
115
|
puts "true"
|
114
116
|
|
@@ -116,6 +118,10 @@
|
|
116
118
|
|
117
119
|
end
|
118
120
|
|
121
|
+
end
|
122
|
+
|
119
123
|
end
|
120
124
|
|
125
|
+
|
126
|
+
|
121
127
|
```
|
1
コメントで頂いた指摘を基に書き直しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -79,3 +79,43 @@
|
|
79
79
|
|
80
80
|
|
81
81
|
win10でRuby 2.6.6p146を動かしています
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
### 追記
|
86
|
+
|
87
|
+
```Ruby
|
88
|
+
|
89
|
+
puts "値を入力"
|
90
|
+
|
91
|
+
i = gets.chomp.to_i
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
if i == 0 || i == 1 || i == 2
|
96
|
+
|
97
|
+
puts "false"
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
else
|
102
|
+
|
103
|
+
(2..i-1).each do |num|
|
104
|
+
|
105
|
+
if 0 == i % num
|
106
|
+
|
107
|
+
puts "false"
|
108
|
+
|
109
|
+
break
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
puts "true"
|
114
|
+
|
115
|
+
break
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
```
|