18 "output_type": "execute_result"
23 "load 'array-numbers.rb'"
41 "output_type": "execute_result"
45 "def truncations(n)\n",
46 " ds = n.to_digits\n",
48 " (0...(dsl-1)).flat_map {|i| [ds[0..i].to_i, ds[(i+1)..dsl].to_i]}\n",
67 "output_type": "execute_result"
89 "output_type": "execute_result"
93 "def truncatable_prime(n)\n",
94 " n.prime? && truncations(n).all? {|i| i.prime?}\n",
100 "execution_count": 7,
111 "execution_count": 7,
113 "output_type": "execute_result"
117 "truncatable_prime(3797)"
122 "execution_count": 8,
133 "execution_count": 8,
135 "output_type": "execute_result"
139 "truncatable_prime(3799)"
144 "execution_count": 9,
152 "[23, 37, 53, 73, 313, 317, 373, 797, 3137, 3797, 739397]"
155 "execution_count": 9,
157 "output_type": "execute_result"
161 "(10..(10**6)).select {|n| truncatable_prime(n)}.to_a"
166 "execution_count": 10,
174 "[23, 37, 53, 73, 313, 317, 373, 797, 3137, 3797, 739397]"
177 "execution_count": 10,
179 "output_type": "execute_result"
183 "(10..(10**10)).lazy.select {|n| truncatable_prime(n)}.take(11).to_a"
188 "execution_count": 11,
199 "execution_count": 11,
201 "output_type": "execute_result"
205 "(10..(10**7)).lazy.select {|n| truncatable_prime(n)}.take(11).sum"
210 "execution_count": null,
220 "display_name": "Ruby 2.4.0",
225 "file_extension": ".rb",
226 "mimetype": "application/x-ruby",