teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

修正

2018/10/18 05:27

投稿

退会済みユーザー
answer CHANGED
@@ -15,7 +15,7 @@
15
15
 
16
16
  # rubyっぽく書くなら -----
17
17
  (1..10).each do |x|
18
- next if 7/x != 0 || 7.divmod(x)[1] == 0
18
+ next if 7/x == 0 || 7.divmod(x)[1] == 0
19
19
  hash[x] = 7.divmod(x)
20
20
  end
21
21
  end

1

rubyっぽく書いた

2018/10/18 05:26

投稿

退会済みユーザー
answer CHANGED
@@ -13,6 +13,14 @@
13
13
  end
14
14
  end
15
15
 
16
+ # rubyっぽく書くなら -----
17
+ (1..10).each do |x|
18
+ next if 7/x != 0 || 7.divmod(x)[1] == 0
19
+ hash[x] = 7.divmod(x)
20
+ end
21
+ end
22
+ # --------------------
23
+
16
24
  hash
17
25
  #=> {2=>[3, 1], 3=>[2, 1], 4=>[1, 3], 5=>[1, 2], 6=>[1, 1]}
18
26
  ```