18 "output_type": "execute_result"
40 "output_type": "execute_result"
44 "def gb_test_one(n, s)\n",
45 " p = n - 2 * s ** 2\n",
52 "execution_count": 10,
63 "execution_count": 10,
65 "output_type": "execute_result"
69 "def other_goldbach(n)\n",
70 " s_limit = Math.sqrt(n / 2).floor\n",
71 " (1..s_limit).any? {|s| gb_test_one n, s}\n",
77 "execution_count": 11,
88 "execution_count": 11,
90 "output_type": "execute_result"
99 "execution_count": 28,
110 "execution_count": 28,
112 "output_type": "execute_result"
116 "def sequence(&generator)\n",
117 " Enumerator.new do |yielder|\n",
120 " yielder.yield generator.call(n)\n",
129 "execution_count": 40,
137 "#<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: #<Enumerator::Generator:0x00557af0bf6f10>:each>>:drop(1)>:select>"
140 "execution_count": 40,
142 "output_type": "execute_result"
146 "odds = sequence {|i| 2 * i + 1}\n",
147 "candidates = odds.lazy.drop(1).select {|i| !i.prime?}"
152 "execution_count": 41,
160 "[9, 15, 21, 25, 27, 33, 35, 39, 45, 49]"
163 "execution_count": 41,
165 "output_type": "execute_result"
169 "candidates.take(10).force"
174 "execution_count": 44,
185 "execution_count": 44,
187 "output_type": "execute_result"
191 "candidates.reject {|i| other_goldbach i}.take(1).force"
196 "execution_count": null,
206 "display_name": "Ruby 2.4.0",
211 "file_extension": ".rb",
212 "mimetype": "application/x-ruby",